重定向会话超时后登录页面 [英] Redirect to login page after session timeout

查看:241
本文介绍了重定向会话超时后登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发现了一些类似的问题,但没有给我什么,我真正需要的。

I have found some similar questions but none gave me what I really need.

下面的东西,我已经加入这个我的web.config 来处理用户会话过期:

Here is the thing, I have added this to my web.config to handle user session expiration:

<sessionState mode="InProc" timeout="1" />

1分钟后,从 Session_End中事件的Global.asax 上升:

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
    Response.Redirect("Login.aspx")
End Sub

这是不行的,因为:

Response is not available in this context.

(顺便说一句,<一个href="http://stackoverflow.com/questions/6264421/how-to-redirect-to-home-page-after-session-timeout/6264446#6264446">this问题得到一个anwswer讲,这是确定的,它得到了upvotes)。

(By the way, this question got an anwswer telling that this is ok and it got upvotes).

我不希望没有什么花哨。我只想要一个简单的方法将用户重定向到登录页面时,会议时间到期。这一切。

I don't want nothing fancy. I just want a simple way to redirect the user to the login page when the session time expires. That's all.

感谢你。

推荐答案

Session_End中是一个服务器端事件,这意味着它引发的Web服务器上,并没有任何与该请求客户。这就是为什么请求无效。

Session_End is a server-side event, meaning it is triggered on the web server and has nothing to do with a request by the client. This is why the Request is unavailable.

您有两个选择在这件事情:

You have two choices in this matter:

  1. 在每个客户端请求,检查是否有特定的会话变量设置。如果不是,则意味着previous会话已经过期,新的会议,必须填充。 (我假定这就是为什么你要检查会话过期)

  1. On each client request, check if a specific Session variable is set. If it is not, it means the previous Session has expired and the new Session must be populated. (I am assuming this is why you want to check for Session expiration)

有周期性返回到服务器,以检查会话是否仍然有效的客户端上的JavaScript调用。如果会话已过期,您可以发出警告,他们的会话即将过期的用户。

Have a javascript call on the client that periodically goes back to the server to check if the Session is still valid. If the Session has expired, you can warn the user that their Session is about to expire.

心连心

这篇关于重定向会话超时后登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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