gpt4 book ai didi

asp.net - session 在 20 分钟后过期 : Whether idle or not

转载 作者:行者123 更新时间:2023-12-02 18:32:21 25 4
gpt4 key购买 nike

我遇到了用户在填写申请表时丢失 session 数据的问题。看来他们在申请表中途丢失了 session 状态。 (ASP.NET 4.0 WebForms 项目,IIS 6.0)

session 存储在状态服务器的进程外,因此它不是配置更改、应用程序域回收等 AFAIK。

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

我正在使用表单例份验证,滑动过期工作正常,您可以从下面的日志记录中看到 - 您可以看到票证过期时间是正确的,并且按预期延长。

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

我启用了一些自定义日志记录来尝试追踪此问题。每 Session_Start火灾global.asax我会记录一些内容,每次有人加载申请表或单击“下一步”在各部分(在多 View 中)之间移动时,我也会记录一些内容,因为他们浏览应用程序表单。

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

日志记录还记录用户的 IP 地址和 session ID。在将它们粘贴到此处之前,我已将其删除,我可以确认所有日志条目的 IP 地址和 session 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]

Example 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 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]

You can see in the first example that the session originally started at 13:07 but was also started at 13:28.

You can see in the second example that the session originally started at 17:44 and was restarted at 18:07.

I understand that these times are 20 minutes after the session started. But the session was not idle. You can see it was not idle because of the rest of the log. Clicking "Next" in the application form gets something an object out of session state

Dim m As Member = StateManager.CurrentMember

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

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

用户正在丢失 session 状态,因为 StateManager.CurrentMember(即 HttpContext.Current.Session("CurrentMember") )返回 null。当我尝试将其附加到 Entity Framework 数据上下文时,这会给出未处理的异常 - 因此用户会看到我的通用错误处理页面。

任何想法表示赞赏。

最佳答案

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

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

关于asp.net - session 在 20 分钟后过期 : Whether idle or not,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4024208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com