ASP.NET 会话很快就会过期?

发布于 2024-08-01 20:05:43 字数 785 浏览 5 评论 0原文

奇怪的问题! ASP.NET 会话立即过期。 在我的 web.config 中,我有以下会话设置:

<sessionState mode="InProc" timeout="10000" />

AFAIK 超时属性的值位于 分钟,且不能大于 525,600 分钟(1 年)。 我不明白我在这里做错了什么。 为什么会话过期。 是服务器内存问题吗? 我不这么认为,服务器相当低劣,而且只有一个站点,毕竟没有做太多事情。 有想法吗?
编辑:
将 Cookiless 属性设置为 true 后,在注意 url 上的会话 ID 时,我可以看到会话 ID 正在更改。 我认为这意味着会话即将到期。 IIS 设置据我所知是正确的(启用会话状态复选框已选中,时间值为 20)。 一张图片胜过100个字:

替代文本 http://img148.imageshack.us/img148/5053/sessionstate.jpg< /a>

Weired problem! ASP.NET Session expires instantly. In my web.config I have this session settings:

<sessionState mode="InProc" timeout="10000" />

AFAIK the timeout attribute's value is in minutes and can't be greater than 525,600 minutes (1 year). I don't understand what I am doing wrong here. Why is the session expiring. Is it a server memory issue? I don't think so, the server is pretty descent and it has only one site which isn't doing much after all. Ideas?


EDIT:
After setting the cookiless attribute to true, and while noticing the session id on the url, I can see that the session id CHANGING. I assume that this means the session is expiring. The IIS Settings are correct AFAIK (the enable session state checkbox is checked, and the value of the time is 20). A Picture is worth 100 words:

alt text http://img148.imageshack.us/img148/5053/sessionstate.jpg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

铁憨憨 2024-08-08 20:05:43

也许您的浏览器没有正确存储 cookie。 尝试将会话设置为 无 cookie 模式,然后重试。

<sessionState mode="InProc" timeout="10000" cookieless="true" />

Perhaps your browser doesn't store cookies correctly. Try setting session to cookieless mode and try again.

<sessionState mode="InProc" timeout="10000" cookieless="true" />
我也只是我 2024-08-08 20:05:43

您需要确保 IIS 以及 web.config 中启用了会话。

另外,值得在应用程序重新启动时记录一些日志。 您可能还有其他问题导致整个应用程序重置。

You need to make sure Session is enabled with IIS as well as in the web.config.

Also, it's worth putting some logging on the Application Restart. You might have something else going wrong that is causing the whole app to reset.

可是我不能没有你 2024-08-08 20:05:43

结果是我们的一位团队成员犯了一个错误,他将会话设置为进程内,尽管站点分布在 4 台具有负载平衡的物理机器上。 我不确定这是否是问题所在,但是当我将其更改为将会话存储在 SQL 服务器中时,它起作用了! 将更深入地研究这个问题并报告我可能获得的任何进一步信息。 谢谢大家!

It turned to be a mistake of one of our team members, he was setting the session to be inproc though the site was distributed of 4 physical machines with Load-Balancing. I'm not sure if it's the problem though, but when I changed it to store the session in a SQL server, it worked! Will dig deeper this issue and report any further information I might get. Thanks you all Guys!

梦里泪两行 2024-08-08 20:05:43

我曾经在一个页面上发生过这种情况。 事实证明,我在一个我没有意识到在执行序列中被调用的地方执行了 Session.Abandon() (它与登录和我使用会员资格提供程序的方式有关)。 作为调试技巧,我建议在每个 Session.Abandon() 上放置一个断点,并确保它不会在您不期望的时候被调用。

I had this happen with a page once. It turns out that I was doing a Session.Abandon() in a place that I did not realize was called in the execution sequence (it related to login and the way I was using the membership provider). As a debugging tip, I would recommend putting a breakpoint on every Session.Abandon() and making sure that it's not being called when you don't expect it.

梦幻的味道 2024-08-08 20:05:43

这种情况在我身上发生过几次,而罪魁祸首一直都是。

有人更新了 Web 应用程序中的文件,导致其重新启动,这种情况通常发生在有人决定更新 web.config 中的某些内容而没有意识到这会导致所有会话被删除时。

对我来说造成这种情况的另一件事是 IIS 中的一个设置,它定义了会话持续多长时间,如果您进入虚拟目录/网站的属性并单击配置,选项选项卡上会显示会话超时持续时间,请检查这是启用并设置为足够高的值。

This has happened to me a couple of times and the main culprits have always been.

Someone updated a file in the web application causing it to restart, this normally happens when someone decides to update something in the web.config without realising this causes all the sessions to be dropped.

The other thing that has caused it for me is a setting in IIS that defines how long sessions last, if you go into the properties of your virtual directory/web site and click configuration, on the options tab is a session timeout duration check this is enabled and set to a high enough value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文