用心感受生活
I can make you smile.
做个平凡、快乐、自信的小女人!

在web.config中,设置:
<sessionState ... timeout="120" />单位是分钟,默认是20

webconfig中设置
<sessionState
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false"
            timeout="20"
    />
timeout可以设置你想要的时间

能否做一个统一的处理,点击任何页面,发现Session超时时进入到提示页面?
你可以把这个判断的过程,放在页面的OnInit事件中.
1.写一个类,继承System.Web.UI.Page,在里面添加如下语句
protected override void OnInit(EventArgs e)
{
if(this.Session["aa"] == null)
{
this.Response.Write("未登录");
this.Response.Redirect("/login.aspx");
}
}
2.在页面中,继承此类
public class WebForm1 : mydata.webui.PageBase

如此,每次打开页面时,都会先判断是否登录,如果没有,则自动转到登录页面去

posted on 2005-12-26 21:15  为自己加油!  阅读(5235)  评论(0编辑  收藏  举报