重定向过程可能不会发生 [英] Redirection process not may occur

查看:99
本文介绍了重定向过程可能不会发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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!


这篇关于重定向过程可能不会发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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