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

asp.net-mvc, c#

Solution

You must read the configuration manually like this:

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

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

Problem

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?

Original source