【问题标题】:why response.redirect cant able to redirect the page once session is expired in global.aspx?为什么在 global.aspx 中的会话过期后 response.redirect 无法重定向页面?
【发布时间】:2014-09-08 04:44:36
【问题描述】:

The response.redirct cant redirect the necessary page while session is expired in global aspx page.

我尝试了以下代码,但没有成功!!!

我尝试了 Response.Redirect 以及 Server.Transfer

        Context.Server.ClearError() 
        Context.Response.AddHeader("Location", "~/frmError.aspx") 
        Context.Response.TrySkipIisCustomErrors = True 
        Context.Response.StatusCode = CInt(System.Net.HttpStatusCode.Redirect) 
        Context.Response.Output.Close() 
        Context.Response.End()

【问题讨论】:

  • 在 globel.asax 的 Session_End 事件中编写代码

标签: c# asp.net vb.net session web


【解决方案1】:

从哪里调用 Response.Redirect?

您是否尝试从protected void Session_End(object sender, EventArgs e) 调用它?

会话过期后究竟发生了什么?重定向到登录页面?

【讨论】:

  • 那么如果会话过期,我如何重定向到任何中间页面?
  • 我发现这是不可能的。因为会话过期的工作原理:此方法在内部调用,无需请求。并且在服务器上的会话过期并且使用此旧 session_id 的请求后,服务器无法识别该 id 并创建新的。唯一认为你能做的就是处理创建新会话。例如检查 Session.IsNewSession.
猜你喜欢
  • 2021-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-04
  • 1970-01-01
  • 1970-01-01
  • 2018-08-22
  • 1970-01-01
相关资源
最近更新 更多