February 2007 Entries

Pluralsight News

Fritz broke the news on Friday. I've joined the esteemed staff of Pluralsight!

What's Wrong With This Code (#12)

Joe Developer has been fired. Sacked. Terminated. Dismissed. Booted. "Dis-employed", if you will. Before Joe left, he started to write one last piece of code. He was asked to write an HTTP Module in ASP.NET that will log some information, and will include the date and time when the application last started running. He learned his lesson in last week's misadventure (too little, too late), and made his DateTime field static, like so: using System; using System.Web; public class LoggingModule : IHttpModule {     public void Init(HttpApplication context)     {         startTime = DateTime.Now;     }     public void Dispose()     {     }     static DateTime startTime; } Joe's replacement, Estelle Hertz, has to finish the module Joe started. Estelle...

Windows Workflow Foundation and ASP.NET

My latest article shows how to drive an ASP.NET web form using a state machine workflow. The sample is based loosely on the Ordering State Machine smart client sample in the SDK, but adds a few real world requirements.

Sorting the Visual Studio "Add New Item" Dialog with PowerShell

The items in the "Add New Item" dialog box of Visual Studio appear in an arbitrary order. After a bit of sleuthing, I put together a brute force Powershell script to sort my items alphabetically. Now "Code File" appears near "Class", and I can always find "XML File" near the bottom of the dialog. SortOrder, and my sanity, is restored. What follows is the script. Download sort-vsItems.ps1. Let me caveat this script by saying it has only been tested on two machines. If you have any problems, do let me know. # sort-vsItems# scott@OdeToCode.com# Modified by AlexanderGross at gmx...

What's Wrong With This Code? (#11)

Joe Developer is tasked with displaying the start date of his ASP.NET application. Joe thinks he'll just add a DateTime field to global.asax and initialize the field during the Application_Start event. <%@ Application Language="C#" %> <script runat="server">     void Application_Start(object sender, EventArgs e)     {         StartDateTime = DateTime.Now;     }          public DateTime StartDateTime;            </script> Whenever Joe needs to display the application start date, he accesses this public field. Joe doesn't know what is wrong, but he is sure of one thing – the date that is displaying on his pages is not the date when the application started. Can you help out Joe one more time?

Sneak Peek: ASP.NET and Windows Workflow

I’ve been working on an article that will show how to use a Windows Workflow state machine to drive logic behind an ASP.NET web form. Generally, my approach in articles is to use just enough code to reveal a specific concept. I don’t use heavy abstractions or include the safeguards and proven practices we need for production applications. There is delicate balance to strike when devising sample code, and you can never please everyone. Simple code will find itself cut and pasted into situations where it shouldn’t exist, and the person who has to fix the situation will curse you...