如何使Asp.net会话在时间范围内到期 [英] How to Expire Asp.net session in time bound
本文介绍了如何使Asp.net会话在时间范围内到期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我的问题是在我的应用程序中,我希望用户在idel中停留5分钟,然后该页面想重定向到登录页面,并且当用户登录时,我要使会话过期我要直接重定向到会话过期页面, 请给我解决方案
Hi my problem is in my application i want to expire a session when user is in idel for 5 minutes and then the page want to redirect to login page and when user login I Want TO Redirected to Session expired page directly please send me the solution
推荐答案
尝试一下..
Try this..
<configuration>
<system.web>
<sessionState timeout="60"/>
</sessionState>
</system.web>
</configuration>
您可以在SessionState中添加mode ="InProc" cookieless ="false".
您还可以在.cs文件中编写以下解决方案
You can add mode="InProc" cookieless="false" in SessionState.
You can also write the following solution in .cs file
Session.Timeout = 60;
您可以将所需时间设置为60.
You can set your desired time in place of 60.
添加Global.asax并在session_end事件上重定向到会话exp页面
Add Global.asax and on session_end event redirect to session exp page
void Session_End(object sender, EventArgs e)
{
Response.Redirect("Your page")
}
这篇关于如何使Asp.net会话在时间范围内到期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文