asp.net - 请求在此上下文中不可用

标签 asp.net iis-7

我正在运行 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/

相关文章:

c# - ContentPage 控件 (mv) --> MasterPage 访问

multithreading - 在 IIS 下增加 .NET Remoting 应用程序的并发请求

iis-7 - 简单的尾部斜杠 URL 重写

asp.net - 动态添加控件到面板 - 布局问题

javascript - 用asp.net中的标签文本替换href值

c# - 使用 Entity Framework 的存储库模式检索复杂对象图的模式

java - HttpPost到asp服务器上(HTML形式)

asp.net - OutputCache 在持续时间之前过期

angularjs - visual studio 错误 :Unable to start debugging on the web server. 远程服务器返回错误:(403) Forbidden

performance - 优化运行 IIS7 的 Windows Server 2008 机器以仅提供静态文件的最佳方法是什么?