ASP.NET MVC FormsAuthentication Cookie 超时无法增加
使用默认的 ASP.NET MVC 模板,我无法弄清楚如何增加 FormsAuthentication 超时。好像总是用30分钟。
我遵循了 Scott Gu 在这篇博文中的建议,但这似乎没有什么区别。有人有建议吗?
他的建议是在 web.config 文件中设置超时值:
<system.web>
<authentication mode="Forms">
<forms timeout="2880"/>
</authentication>
</system.web>
Using the default ASP.NET MVC template, I cannot figure out how to increase the FormsAuthentication timeout. It seems to always use 30 minutes.
I have followed Scott Gu's recommendation from this blog post, but it does not seem to make a difference. Does anyone have a suggestion?
His suggestion was to set the timeout value in the web.config file:
<system.web>
<authentication mode="Forms">
<forms timeout="2880"/>
</authentication>
</system.web>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,并将带有 ValidationKey 的自定义 MachineKey 添加到 web.config 解决了该问题。它似乎会影响共享主机。
我使用这个网站生成随机机器密钥:
http://aspnetresources.com/tools/machineKey
I had the same problem and adding a custom MachineKey with a ValidationKey to the web.config solved the problem. It seems to affect shared hosts.
I used this site to generate a random machine key:
http://aspnetresources.com/tools/machineKey
确保您在 ~/Web.config 文件而不是 ~/Views/Web.config 文件中进行设置。另外,大约 5000 万分钟。 100 年,这可能会导致浏览器中出现一些与日期相关的溢出。尝试使用更合理的数字,例如 2 - 3 年(150 万分钟)。
Be sure that you are setting this in the ~/Web.config file and not in the ~/Views/Web.config file. Also, 50 million minutes is approx. 100 years, which might be hitting some date-related overflow in the browser. Try using a more reasonable number like 2 - 3 years (1.5 million minutes).
我的问题仅发生在我的网络主机的生产环境中。
我找到了此链接并生成了一个机器密钥以放入 web.config 中。一旦我这样做了,超时值就生效了。
My issue was only occurring in my production environment at my web host.
I found this link and generated a machine key to put in the web.config. Once I did that, the timeout value took effect.