Found this post earlier and well worth sharing; I have wanted to know how to do this for sometime. I have googled, searched books etc but never come up with the answer.
Fortunately there are smarter and more experienced people out there than me and Rick Strahl is one of them, if you don't subscribe to his blog I recommend it.
He has posted some code on how to find out if the application is running in debug mode...turns out its pretty simple and if I had spent sometime with intellisense (the best help source out there!) I would have found it.
Basically (ripped from Rick's Post).....
Script = OptimizeScript(Script);
Further.....there are a couple of comments than discuss the topic further.
From Wilco Bauwer he comments that this property encapsulates the web.config setting and doesn't take the page level debugging into account and it you wanted to....
bool isDebuggingEnabled = Assembly.GetExecutingAssembly().IsDefined(typeof(DebuggableAttribute));
....this is the kiddy to achieve it!!
and Peter Bromberg (C# MVP) offers up another solution using the Global.asax.cs file and a static global application flag being set in the Application_Start event.
public static bool IsDebugMode = false;
protected void Application_Start(object sender, EventArgs e)
if (System.Diagnostics.Debugger.IsAttached) IsDebugMode = true;
This is definitely my find of the year (so far!)