This blog has moved!

Check out www.CodeBetter.com/blogs/grant.killian

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Professional Props...

Extracurricular Props...

Subscriptions

Article Categories



My latest little tactic (no Web Service dust involved) . . .

. . . has been to take advantage of the Debug conditional compilation constants and Trace and Assert to my heart's content.  It also lets me circumvent some time consuming authentication code or pre-fill forms with test values, etc.  It can be as simple as the following in the global.asax Session_Start() event handler:

#if( DEBUG )
    Session.Contents[ "Authenticated" ] = "true" ;
#else
   //no special action
#endif

When you do a Debug build, the DEBUG constant evaluates to true; if you do a Release build -- shocker -- the Debug constant is false.  It's all handled automatically by Visual Studio .Net from the Project Properties->Build->Code Generation section (by default TRACE is another constant defined for Debug AND Release builds).

I know this isn't a glitzy new feature with XML baked in and Web Service dust sprinkled on it, but it is a nice little measure to remember!  By the way, my above example using a Session variable is very bug prone . . . for production code I make a typed session manager like Mark does here.

Happy .Netting!

posted on Wednesday, June 16, 2004 10:10 AM by grant.killian





Powered by Dot Net Junkies, by Telligent Systems