重定向过程可能不会发生

重定向过程可能不会发生

问题描述:

在Global.asax文件中,会话超时后,重定向过程显示错误,因为在此上下文中没有响应".

我的代码在这里:

In Global.asax file After session timeout the redirection process shows error as "Response is not available in this context".

my code is here:

protected void Session_End(object sender, EventArgs e)
        {
            Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\Index.aspx));
        }



请帮忙



pls help

简单:HttpContext在Session_End事件(或Session_Start事件)中均不可用,因为它与任何请求都没有关联(即请求已不是来自客户端-如果有的话,则意味着会话毕竟不会结束).整个想法是会话不再存在,没有连接可供您重定向!
Simple: The HttpContext is not available in the Session_End event (or the Session_Start event either) because it is not associated with any request (i.e. the request did not come from the client - which if it had would mean that the session is not ending after all). The whole idea is the session no longer exists, there is no connection for you to redirect!