首页 新闻 赞助 找找看

Request is not available in this context

0
悬赏园豆:30 [待解决问题]

在Application_Start中虽然进行了Request是否为null的判断:

if (Context != null)
{
    if (Context.Request != null)
    {
    }
}

但依然会触发异常:

[HttpException (0x80004005): Request is not available in this context]
System.Web.HttpContext.get_Request() +11915008

请问如何可以避免这样的异常?

问题补充:

这个异常是根据HideRequestResponse进行判断的,详见HttpContext.cs的第907行:

public HttpRequest Request {
    get {
         if (HideRequestResponse)
            throw new HttpException(SR.GetString(SR.Request_not_available));
        return _request;
    }
}

相关提问:

Workaround for HttpContext.HideRequestResponse being internal? Detect if HttpContext.Request is really available?

dudu的主页 dudu | 高人七级 | 园豆:31075
提问于:2015-01-05 12:34
< >
分享
所有回答(1)
0

给你个 参考网址..怎么解决Context.Request异常
http://www.cnblogs.com/dudu/archive/2011/10/14/Application_Start_Context_Request.html

_jie | 园豆:116 (初学一级) | 2015-01-05 14:16

汗!这就是我写的博客,竟然忘记了。。。

支持(0) 反对(0) dudu | 园豆:31075 (高人七级) | 2015-01-05 15:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册