我正在运行 IIS 7 集成模式,并且我得到了
请求在此上下文中不可用
当我尝试在从 Application_Start
调用的 Log4Net 相关函数中访问它时。这是我的代码行
if (HttpContext.Current != null && HttpContext.Current.Request != null)
第二次比较时抛出异常。
除了检查 HttpContext.Current.Request 是否为 null 之外,我还能检查什么?
<小时/>类似的问题已发布@ Request is not available in this context exception when runnig mvc on iis7.5
但也没有相关答案。
最佳答案
请参阅IIS7 Integrated mode: Request is not available in this context exception in Application_Start :
The “Request is not available in this context” exception is one of the more common errors you may receive on when moving ASP.NET applications to Integrated mode on IIS 7.0. This exception happens in your implementation of the Application_Start method in the global.asax file if you attempt to access the HttpContext of the request that started the application.
关于asp.net - 请求在此上下文中不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2518057/