请求在此上下文中不可用 [英] Request is not available in this context

查看:44
本文介绍了请求在此上下文中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 IIS 7 集成模式,并且正在运行

I'm running IIS 7 Integrated mode and I'm getting

请求在此上下文中不可用

当我尝试在从 Application_Start 调用的 Log4Net 相关函数中访问它时.这是我的代码行

when I try to access it in a Log4Net related function that is called from Application_Start. This is the line of code I've

if (HttpContext.Current != null && HttpContext.Current.Request != null)

并且正在抛出异常以进行第二次比较.

and an exception is being thrown for second comparison.

除了检查 HttpContext.Current.Request 是否为 null 之外,我还能检查什么??

What else can I check other than checking HttpContext.Current.Request for null??

发布了一个类似的问题@请求不可用在 iis7.5 上运行 mvc 时出现此上下文异常

A similar question is posted @ Request is not available in this context exception when runnig mvc on iis7.5

但那里也没有相关的答案.

but no relevant answer there either.

推荐答案

请参阅 IIS7 集成模式:Application_Start 中的此上下文异常中的请求不可用:

请求在此不可用上下文"异常是其中之一您可能会在以下情况下收到的常见错误将 ASP.NET 应用程序移动到IIS 7.0 上的集成模式.这个异常发生在你的的实施Application_Start 方法在global.asax 文件,如果您尝试访问请求的 HttpContext启动应用程序.

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.

这篇关于请求在此上下文中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆