Aran Mulholland
Aran Mulholland

Reputation: 23945

Determine if application is running in debug mode without using httpcontext. (asp.net)

In an ASP.NET MVC program you can use

HttpContext.Current.IsDebuggingEnabled

In order to determine if debug="true" in the web.config.

How do I do this without referring to the HttpContext?

Upvotes: 4

Views: 2017

Answers (1)

DavidG
DavidG

Reputation: 119116

You must read the configuration manually like this:

var compilation = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");

if (compilation.Debug)
{
    //Debug is on!
}

Upvotes: 8

Related Questions