Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net-mvc

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?

like image 440
Aran Mulholland Avatar asked Feb 12 '23 21:02

Aran Mulholland


1 Answers

You must read the configuration manually like this:

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

if (compilation.Debug)
{
    //Debug is on!
}
like image 179
DavidG Avatar answered Feb 15 '23 10:02

DavidG