Form Cookie Expiring too soon on production server

时间秒杀一切 提交于 2020-01-24 21:06:17

问题


i have following settings in web.config

<authentication mode="Forms">
      <forms loginUrl="~/Account/login"   
       slidingExpiration="true" timeout="2880" protection="All" />
 </authentication>

but the cookie expires in less than five minutes of inactivity. Any clue on what is happening?


回答1:


I recognize this behavior from a web host where I run one of my sites. It all started when moving to new servers, prepared for dotNET 4. The web.config is completely ignored and, as you mention, five minutes seems to be the break-point.

Your question made me start digging around, looking for a working. I started by browsing the forms-authentication category here on Stackoverflow, one of the tags you used. After a few minutes I found a somewhat similar question: ASP.NET forms authentication keeps displaying login page. In the accepted answer it was suggested to set cookieless="UseCookies.

I checked my own web.config and found that cookieless was left out, falling back on the default configuration. A quick edit and some testing gave a positive result. It worked great. But then I edited the file back, as it was before and have now had a working session for ten ours. I added a meta-refresh which reloaded the page every ten minutes. Perhaps the hosting company have tweaked some parameter. The sad thing is I have no solution for you :(

Instead of running your service in the web server shipped with with Visual Studio, try to run it locally in IIS and see if you can reproduce the issue.

(To help users answer this questions I guess it would help if you provide some info about the production server, component versions and stuff. Like which version of IIS you're running and which framework version you build for. And, when you run your site in test do you use IIS or the light-weight web server in Visual Studio?)



来源:https://stackoverflow.com/questions/6557023/form-cookie-expiring-too-soon-on-production-server

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