Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从ApiController内部启用ISdebugging_C#_Asp.net_Asp.net Mvc_Asp.net Web Api - Fatal编程技术网

C# 从ApiController内部启用ISdebugging

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.

我有一个ASP.NET Web API控制器和一个
公共异步任务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)
{
...
}