Asp.net 会话过期时如何重定向页面
我在web配置中使用了以下代码,但它不能正常工作。建议您的代码在Asp.net 会话过期时如何重定向页面,asp.net,session,Asp.net,Session,我在web配置中使用了以下代码,但它不能正常工作。建议您的代码在会话过期时重定向 我的代码是: <authentication mode="Forms"> <forms name="MyAuth" timeout="60" protection="All" loginUrl="Login.aspx" slidingExpiration="true" /> </authentication> <sessionState mod
会话
过期时重定向
我的代码是:
<authentication mode="Forms">
<forms name="MyAuth" timeout="60" protection="All" loginUrl="Login.aspx" slidingExpiration="true" />
</authentication>
<sessionState mode="InProc" cookieless="false" timeout="60" />
我使用以下代码:
<authentication mode="Forms">
<forms name="WhateverYourAuthNameIs" loginUrl="~/Login.aspx" defaultUrl="~/Default.aspx" protection="All" path="/" cookieless="AutoDetect" timeout="2880" />
</authentication>
非常适合我。您可以使用session[“sessionName”]检查会话,看看它是否返回null,以及它是否只是使用Response.redirect(“login.aspx”)重定向它们
什么是“工作不正常”?发生了什么?可能是@CodeCaster的重复。当我在20分钟后尝试单击按钮时,它将显示错误。我们无法使用该信息执行任何操作,因为“错误”和“按钮”不会显示任何信息。请参见链接为重复的问题。
if(Session["sessionName"]==null)
{
Response.Redirect("Login.aspx");
}