我在Web.config中使用身份验证的配置
 <authentication mode="Forms"> 
<forms name=".LogonCookie" loginUrl="logon.aspx" timeout="10000"/>        
    </authentication>   <authorization>
       <deny users="?"/>
 </authorization><sessionState 
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false" 
            timeout="5" 
    />然后在logon.aspx中:
session("name")=txtUserName.text
If Request.Params("ReturnUrl") = Nothing Then
   FormsAuthentication.SetAuthCookie(Session("Name"), False)
   Response.Redirect("index.aspx")
Else
   FormsAuthentication.RedirectFromLoginPage(Session("name"), False)
End If
我现在是想在Session超时后,自动跳转到logon.aspx
现在的运行结果是,session超时后不自动跳转,且对session("name")的引用为空串。如何改造才能达到我要的效果?

解决方案 »

  1.   

    判断Session["name"]为null时跳转不行吗?
      

  2.   

    如果用判断Session["name"]为null跳转,那为什么还要身份验证机制?
      

  3.   

    session并不是身份验证机制的必须品,session的丢失并不代表验票失效
      

  4.   

    你应该通过
    FormsAuthentication.RedirectFromLoginPage(username,CheckBox1.Checked);
    登陆,
    通过
    if(Context.Request.IsAuthenticated==true)
    来判断验票是否存在
      

  5.   

    //session has probably timed out force a new logon
    FormsAuthentication.SignOut();
    Response.Redirect(@"xxxxx.aspx", false);
    return;