Why really short timeout in ASP.NET MVC?

让人想犯罪 __ 提交于 2019-12-03 04:16:02

问题


I have an MVC 2 application where the timeout is set to 2880 (minutes as I understand it, but even if it is seconds there's a problem):

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>

Now this should then mean 48 hours, or at least 48 minutes (if the value is seconds). But the user is logged out after as little as a couple of minutes of inactivity...

Why is that? Any help appreciated!


回答1:


Found the answer finally after a lot of Googling...

You have to set a custom machinekey in the web.config file. I used this generator:

http://aspnetresources.com/tools/machineKey

This seems to have to do something with "recycling" on the web host, which causes the user to be logged off, if I understood it correctly.

Anyway, it works fine now!




回答2:


2880 is given in minutes. It will logout automatically if you add slidingExpiration="true". See example below.

 <forms loginUrl="~/Account/LogOn" timeout="2880" slidingExpiration="true"/>


来源:https://stackoverflow.com/questions/3995264/why-really-short-timeout-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!