加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 会话在20分钟后到期:是否空闲

发布时间:2020-12-16 09:33:56 所属栏目:asp.Net 来源:网络整理
导读:用户在浏览申请表时丢失了会话数据,我遇到了一些麻烦.看起来他们正在通过申请表部分失去会话状态. (ASP.NET 4.0 WebForms项目,IIS 6.0) 会话存储在状态服务器的进程外,因此它不是配置更改,appdomain回收等AFAIK. sessionState mode="StateServer" stateConne
用户在浏览申请表时丢失了会话数据,我遇到了一些麻烦.看起来他们正在通过申请表部分失去会话状态. (ASP.NET 4.0 WebForms项目,IIS 6.0)

会话存储在状态服务器的进程外,因此它不是配置更改,appdomain回收等AFAIK.

<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" timeout="20" />

我正在使用表单身份验证,滑动过期工作正常,您可以从下面的日志中看到 – 您可以看到故障单过期时间是正确的并且被扩展为exprected.

<authentication mode="Forms">
   <forms loginUrl="~/Login.aspx" />
</authentication>

我已启用一些自定义日志记录以尝试跟踪此情况.在global.asax中的每个Session_Start fire上,我记录了一些内容,每当有人加载应用程序表单时,我也会记录一些内容,或者当他们浏览应用程序表单时,单击“下一步”以在各个部分之间移动(在MultiView中).

以下是两个失去会话状态的人的例子.日志以日志条目的日期/时间开始,然后是一些措辞.括号中的第二个日期/时间(在措辞之后)是从CType(ctx.User.Identity,FormsIdentity)派生的FormsAuthentication cookie的到期日期/时间.Ticket.Expiration.ToString

日志记录还记录用户的IP地址和会话ID.我在将它们粘贴到这里之前删除了这些,我可以确认所有日志条目的IP地址和会话ID是相同的.

例1:

**[26/10/2010 13:07]    Session started []**
[26/10/2010 13:11]  Application form first Page_Load [26/10/2010 13:31:19]
[26/10/2010 13:13]  App form next clicked,current index is 1 (vwSection1) [26/10/2010 13:31:19]
[26/10/2010 13:14]  App form next clicked,current index is 2 (vwSection2) [26/10/2010 13:31:19]
[26/10/2010 13:15]  App form next clicked,current index is 3 (vwSection3) [26/10/2010 13:31:19]
[26/10/2010 13:20]  App form next clicked,current index is 5 (vwSection4) [26/10/2010 13:31:19]
[26/10/2010 13:20]  App form next clicked,current index is 6 (vwSection5) [26/10/2010 13:31:19]
[26/10/2010 13:20]  App form next clicked,current index is 7 (vwMonitoring) [26/10/2010 13:31:19]
[26/10/2010 13:21]  App form next clicked,current index is 8 (vwInformation) [26/10/2010 13:31:19]
[26/10/2010 13:22]  Application form first Page_Load [26/10/2010 13:41:22]
[26/10/2010 13:25]  App form next clicked,current index is 1 (vwSection1) [26/10/2010 13:41:22]
[26/10/2010 13:26]  App form next clicked,current index is 2 (vwSection2) [26/10/2010 13:41:22]
[26/10/2010 13:26]  App form next clicked,current index is 3 (vwSection3) [26/10/2010 13:41:22]
[26/10/2010 13:28]  App form next clicked,current index is 5 (vwSection4) [26/10/2010 13:41:22]
[26/10/2010 13:28]  App form next clicked,current index is 6 (vwSection5) [26/10/2010 13:41:22]
[26/10/2010 13:28]  App form next clicked,current index is 7 (vwMonitoring) [26/10/2010 13:41:22]
[26/10/2010 13:28]  App form next clicked,current index is 8 (vwInformation) [26/10/2010 13:41:22]
**[26/10/2010 13:28]    Session started [26/10/2010 13:41:22]**
[26/10/2010 13:31]  Application form first Page_Load [26/10/2010 13:51:24]
[26/10/2010 13:31]  App form next clicked,current index is 1 (vwSection1) [26/10/2010 13:51:24]
[26/10/2010 13:32]  App form next clicked,current index is 2 (vwSection2) [26/10/2010 13:51:24]
[26/10/2010 13:32]  App form next clicked,current index is 3 (vwSection3) [26/10/2010 13:51:24]
[26/10/2010 13:32]  App form next clicked,current index is 5 (vwSection4) [26/10/2010 13:51:24]
[26/10/2010 13:32]  App form next clicked,current index is 6 (vwSection5) [26/10/2010 13:51:24]
[26/10/2010 13:32]  App form next clicked,current index is 7 (vwMonitoring) [26/10/2010 13:51:24]
[26/10/2010 13:32]  App form next clicked,current index is 8 (vwInformation) [26/10/2010 13:51:24]

例2:

**[24/10/2010 17:44]    Session started []**
[24/10/2010 17:50]  Application form first Page_Load [24/10/2010 18:10:13]
[24/10/2010 18:00]  App form next clicked,current index is 1 (vwSection1) [24/10/2010 18:20:40]
**[24/10/2010 18:07]    Session started [24/10/2010 18:20:40]**
[24/10/2010 18:08]  App form next clicked,current index is 2 (vwSection2) [24/10/2010 18:20:40]
[24/10/2010 18:10]  App form next clicked,current index is 1 (vwSection1) [24/10/2010 18:30:42]
[24/10/2010 18:10]  App form next clicked,current index is 1 (vwSection1) [24/10/2010 18:30:52]
[24/10/2010 18:10]  App form next clicked,current index is 1 (vwSection1) [24/10/2010 18:30:58]
[24/10/2010 18:12]  Application form first Page_Load [24/10/2010 18:31:35]
[24/10/2010 18:12]  App form next clicked,current index is 1 (vwSection1) [24/10/2010 18:31:35]
[24/10/2010 18:13]  App form next clicked,current index is 2 (vwSection2) [24/10/2010 18:31:35]
[24/10/2010 18:13]  App form next clicked,current index is 2 (vwSection2) [24/10/2010 18:31:35]
[24/10/2010 18:16]  App form next clicked,current index is 3 (vwSection3) [24/10/2010 18:31:35]
[24/10/2010 18:16]  App form next clicked,current index is 5 (vwSection4) [24/10/2010 18:31:35]
[24/10/2010 18:17]  App form next clicked,current index is 6 (vwSection5) [24/10/2010 18:31:35]
[24/10/2010 18:18]  App form next clicked,current index is 7 (vwMonitoring) [24/10/2010 18:31:35]
[24/10/2010 18:18]  App form next clicked,current index is 8 (vwInformation) [24/10/2010 18:31:35]

您可以在第一个示例中看到会话最初在13:07开始,但也在13:28开始.

您可以在第二个示例中看到会话最初从17:44开始,并在18:07重新启动.

我知道这些时间是会议开始后20分钟.但会议并未闲置.由于日志的其余部分,您可以看到它没有空闲.单击应用程序表单中的“下一步”可以获得会话状态之外的对象

Dim m As Member = StateManager.CurrentMember

然后获取/设置“m”的属性.

所以,对我而言,即使用户没有闲置并访问他们的会话变量,他们仍然会在他们开始后20分钟正在丢失他们的会话.请注意,在我的基页(所有页面继承,基页继承System.Web.UI.Page)中,我现在开始将当前毫秒写入会话状态,因此我不断写入会话.

用户正在丢失其会话状态,因为StateManager.CurrentMember(它只是HttpContext.Current.Session(“CurrentMember”))返回null.当我尝试将它附加到实体框架数据上下文时,这会给出一个未处理的异常 – 因此用户可以看到我的通用错误处理页面.

任何想法都赞赏.

解决方法

您提到您正在使用FormsAuthentication.您是否将滑动过期属性设置为true?

http://msdn.microsoft.com/en-us/library/1d3t3c61(v=VS.100).aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读