C# 从ApiController内部启用ISdebugging
我有一个ASP.NET Web API控制器和一个C# 从ApiController内部启用ISdebugging,c#,asp.net,asp.net-mvc,asp.net-web-api,C#,Asp.net,Asp.net Mvc,Asp.net Web Api,我有一个ASP.NET Web API控制器和一个公共异步任务DoThing()方法 在不访问HttpContext.Current(该方法必须是可单元测试的)的情况下,如何确定当前请求的IsDebuggingEnabled 这些对象都不具有此属性: this.Request this.RequestContext this.ActionContext this.ControllerContext 在哪里可以找到isdebuggingsenabled HttpContext.Current.
公共异步任务DoThing()
方法
在不访问HttpContext.Current
(该方法必须是可单元测试的)的情况下,如何确定当前请求的IsDebuggingEnabled
这些对象都不具有此属性:
this.Request
this.RequestContext
this.ActionContext
this.ControllerContext
isdebuggingsenabled
HttpContext.Current.IsDebuggingEnabled
此属性实际上查看web.config配置设置及其仅在HttpContext中的设置。
以下方面应起作用:
var cfg =(System.Web.Configuration.CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
if (cfg.Debug)
{
...
}
此属性实际上查看web.config配置设置及其仅在HttpContext中的设置。
以下方面应起作用:
var cfg =(System.Web.Configuration.CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
if (cfg.Debug)
{
...
}