在那里可以设置session timeout?

fisea 2012-02-13 04:52:29
在任何一个页面随便做一个操作,比如点击操作。然后等20分钟,这个seesion就认为是timeout了并且跳转到timeout.aspx的页面。请问怎么做?
...全文
256 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
porschev 2012-02-14
  • 打赏
  • 举报
回复

一般都会在web.config文件中sessionState节点里设置
lluvianoches 2012-02-14
  • 打赏
  • 举报
回复
loginUrl登录页, defaultUrl登录后显示页

<authentication mode="Forms">
<forms loginUrl="" defaultUrl="" timeout="1440" />
</authentication>
  • 打赏
  • 举报
回复
我个人的建议:重载Page_Load事件



//重写Page基类的OnLoad事件方法
protected override void OnLoad(EventArgs e)
{
//测试
//Session.RemoveAll();
try
{
if (base.Session["user"] == null || base.Session["user"].ToString().Equals(""))
{
this.ClientScript.RegisterStartupScript(GetType(), "", "<script language=javascript>top.location.href='../../Login.aspx'</script>");
//Response.Write("<script language=javascript>top.location.href='../../Login.aspx'</script>");
}
else {
base.OnLoad(e);
}
}
catch (Exception)
{

throw;
}


然后相应的页面

namespace OA.WebAPP.SubModule.XTXX
{
public partial class FBGL : OA.UI.PageBase
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}

红色部位为修改了接口后显示。这样只要进入页面之前都会判断你的SESSION是否失效,然后制定跳转页面
fisea 2012-02-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yanlele424 的回复:]

引用 1 楼 lluvianoches 的回复:

在Web.Config里设
< sessionState mode="Off|InProc|StateServer|SQLServer"
cookieless="true|false"
timeout="number of minutes"
stateConnectionString="tcpip……


除了这个地方 还有……
[/Quote]请问除了设置这个之外,还需要在那里配置跳转的页面(timeout.aspx)?
习惯就好 2012-02-13
  • 打赏
  • 举报
回复

判断session是否过期,你可以在母版页中Page_Load、或者在一个自己写页面基类中(大家一般都会命名为PageBase,让其他页面继承PageBase)的Init_Page中判断session是否过期,如果过期则跳转到timeout.aspx 页面就是了


默认session过期时间是20分钟,可以更改web.config配置

<system.web>
<sessionState timeout="20"> timeout 以分钟为单位
</sessionState>
...
翘楚时代 2012-02-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lluvianoches 的回复:]

在Web.Config里设
< sessionState mode="Off|InProc|StateServer|SQLServer"
cookieless="true|false"
timeout="number of minutes"
stateConnectionString="tcpip……
[/Quote]

除了这个地方 还有IIS中也需要设置:右键站点—》属性—》配置—》选项—》启用会话 设置上时间即可。
lluvianoches 2012-02-13
  • 打赏
  • 举报
回复
在Web.Config里设
< sessionState mode="Off|InProc|StateServer|SQLServer"
cookieless="true|false"
timeout="number of minutes"
stateConnectionString="tcpip=server:port"
sqlConnectionString="sql connection string"
stateNetworkTimeout="number of seconds"
/>

62,068

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧