当会话超时时,这是将用户注销的正确方式吗? 这是我在主页的Page_init中编写的代码。 而且,
会话状态和窗体身份验证是喜欢,当会话超时时注销用户
<sessionState mode="InProc" timeout="1" cookieless="false">
</sessionState>
<authentication mode="Forms">
<forms loginUrl="Default.aspx" timeout="2880"/>
</authentication>
if (userToLogin != null)
{
if (Context.Session != null)
{
if (Session.IsNewSession)
{
HttpCookie newSessionIdCookie = Request.Cookies["ASP.NET_SessionId"];
if (newSessionIdCookie != null)
{
string newSessionIdCookieValue = newSessionIdCookie.Value;
if (newSessionIdCookieValue != string.Empty)
{
**System.Web.Security.FormsAuthentication.SignOut();**
Response.Redirect("SessionTimeOutPage.htm");
}
}
}
}
}
请建议我来说这是正确的方式或东西是可以作为最佳的解决方案。
对不起,也许需要更多的测试。我用这一点来做这样的测试。 – Aristos 2012-07-17 10:38:35