if(Session["key"] == null)
 Response.Redirect("Login.aspx");

解决方案 »

  1.   

    可以在自建的错误页(SystemError.aspx)中加入登陆功能。
    再在WebConfig中设置使用该错误页
    <customErrors mode="ORemoteOnly" defaultRedirect="SystemError.aspx"/> 
    最好能提示用户是Session过期,需重新登陆
      

  2.   

    <authentication mode="Forms">     <!--  APPLICATION-LEVEL TRACE LOGGING
              Application-level tracing enables trace log output for every page within an application. 
              Set trace enabled="true" to enable application trace logging.  If pageOutput="true", the
              trace information will be displayed at the bottom of each page.  Otherwise, you can view the 
              application trace log by browsing the "trace.axd" page from your web application
              root. 
        -->
        <forms name ="assets" path ="/" loginUrl="login.aspx" protection="All" timeout="20"></forms>
        </authentication>
    <authorization>
    <deny users ="?"/>    
        </authorization>
      

  3.   

    请说得详细一点!!!if(Session["key"] == null)
     Response.Redirect("Login.aspx");
    不能满足吗?-----------努力学习 不断实践 虚心讨教---------
      

  4.   

    <forms name ="assets" path ="/" loginUrl="login.aspx" protection="All" timeout="20"></forms>
        </authentication>
    <authorization>
    <deny users ="?"/>    
        </authorization>
    在所有的SESSION过期后都会自动转到LOGIN.ASPX
      

  5.   

    我不想每个页面都写
    if(Session["key"] == null)
     Response.Redirect("Login.aspx");我想在一个地方写,使得Session过期后自动跳到登录页
      

  6.   

    同意 goody9807() ,直接在web.config中配置就可以了
      

  7.   

    我不想写if session("user")="" then ..如何判断session已过期
      

  8.   

    global 中写 session end 事件  事先已经提供
      

  9.   

    session已过期 和会话结束是一个意思吗
      

  10.   

    to Oceanson(洋之光) :不管用
      

  11.   

    按照goody9807()的说法,一运行就停留在Login.aspx中,无法跳转到其他任何页面,请问,这是怎么一回事?该怎么解决?
      

  12.   

    写一个验证页面类,让其他的页面继承它.
    public class FrmJlBMainList : gpt.GptPageList
    {}
    gpt.GptPageList:验证页面类
    FrmJlBMainList:其他页面.
      

  13.   

    goody9807() 
    你的方法不灵啊!总是在登录页面,不能到其他页面啊!你再仔细看看,是否哪儿写错了