Ah the beauty of a big framework. I was doing some work on an internal GZip compression handler and one thing I needed to know is whether the application is running in Debug mode. It’s easy to do this IF you know where to look:


// *** Optimize the script by removing comment lines and stripping spaces

if (!HttpContext.Current.IsDebuggingEnabled)           

    Script = OptimizeScript(Script);   


It took me a while to find this - I was expecting to find this on the HttpApplication object. Didn't have much luck with searching either when finally I stumbled onto it above on the Context object.


Although this is probably not a setting you deal with on a daily basis it can certainly be useful when sending certain output back to the client and of course for test and trace scenarios in your own application code. In this case, the idea is to send back the original file JavaScript.js file and only optimize and mangle that text when not running in debug mode.