在不使用httpcontext的情况下确定应用程序是否在调试模式下运行。 (asp.net)
在ASP.NET MVC程序中,您可以使用
HttpContext.Current.IsDebuggingEnabled
为了确定web.config中是否debug="true"
。
如何在不引用HttpContext的情况下执行此操作?
您必须手动读取配置,如下所示:
var compilation = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation"); if (compilation.Debug) { //Debug is on! }