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

In ASP.NET MVC you can use

HttpContext.Current.IsDebuggingEnabled

To determine if there is debug="true"a web.config file.

How to do this without reference to the HttpContext?

+4
source share
1 answer

You must read the configuration manually as follows:

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

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

Source: https://habr.com/ru/post/1542009/


All Articles