Writing
Articles
Essays on thinking clearly, working for yourself, and doing real work while AI rewrites the rules. Two decades of them.
Generate XML in SQL
Skip DataTable.WriteXml() entirely. SQL Server 2005's FOR XML AUTO clause can generate XML straight from a query. Here's a quick example.
2007.02.19Read →
The hidden Trace page, trace.axd
ASP.NET's built-in trace.axd page shows detailed per-request timing and stats once you flip on tracing in web.config, plus how to log custom output.
2007.02.13Read →Simian Upgrade
Simian's new release quietly dropped the -recurse flag, breaking my CruiseControl.NET build. Here's the fix, plus how fast the vendor patched it.
2007.02.07Read →
Force HTTPS on all requests, HttpModule
How to force every request to HTTPS in classic ASP.NET with a simple IHttpModule, instead of relying on IIS settings or per-page redirects.
2007.02.03Read →Prototype/Proof of Concept code is not production code!
Prototype and proof-of-concept code exists to align with clients, not to ship. Why POC code should never be repurposed into your production app.
2007.02.02Read →The “as” Keyword
A C# 'as' cast gotcha: casting a boxed value type to string silently returns null instead of throwing, unlike a direct cast. Know your types.
2007.01.30Read →New Lines
Stop hardcoding carriage-return-and-newline pairs in your C# strings. Use the built-in Environment.NewLine property so your code adapts to any platform.
2007.01.17Read →Escaping String Literals
A simple C# trick: prefix a string with @ to stop escaping backslashes in file paths, plus the one case where it still trips you up.
2007.01.14Read →
Warnings as Errors
Why I configure every .NET project to treat compiler warnings as build-breaking errors, and how to turn it on in Visual Studio or csc.exe.
2007.01.11Read →ASP.NET File Name at Runtime
A quick ASP.NET snippet and base Page class for grabbing the current page's file name at runtime without repeating the same helper everywhere.
2007.01.10Read →Hiding Code From The Debugger
Tired of stepping through helper methods you already know work? The DebuggerHidden attribute tells the debugger to skip that code entirely.
2007.01.09Read →Conditional Switch Statement with Enumeration String Value
How to switch on a string value of a C# enum without hitting the 'a constant value is required' compiler error - just Enum.Parse it first.
2007.01.06Read →