Response.IsAuthenticated Is False After 30 Seconds

放肆的年华 提交于 2020-01-15 14:29:12

问题


I have an ASP.NET MVC3 application deployed to a shared hosting service. It uses FormsAuthentication and SSL:

<authentication mode="Forms">
  <forms loginUrl="~/Home/Index" timeout="240" requireSSL="true" />
</authentication>

The problem is in some Razor (partial) views: I execute a callback to a controller method which, for purposes of testing, simply sleeps and returns a PartialView. My question revolves around Response.IsAuthenticated. It is true before the callback and sleep and remains true afterwards as long as the sleep is 30 seconds or less. However, I've tested it with various longer durations (e.g. 55 seconds) and Response.IsAuthenticated becomes false in those cases. This is a problem because in my original code I need to do a redirect (via JS, open.window, in my Partial View). Since Response.IsAuthenticated is false FluentSecurity immediate sends the user to the loginUrl (which I don't want).

It seems that this would be related to a timeout somewhere ("KeepAlive","ServerTimeout"?) but I've Googled response.isauthenticated timeout and come up with nothing. Frankly, this behavior seems to be occurring throughout the site: if the user leaves the page sitting (I'm using FF) for more than a minute or so then when they try to access a page they are automatically being redirected to the loginURL. Note that my session timeout is set to "120". Funny thing is I did not experience this behavior when the app was deployed to Windows Azure (there were other issues, though); it just started happening when I switched to a different host.

Any pointers to info on this topic would be appreciated.


回答1:


Maybe the host is killing the AppPool in the server when it is a few seconds idle.

You log the app ShutDown event to see if that's the case: http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx



来源:https://stackoverflow.com/questions/12352931/response-isauthenticated-is-false-after-30-seconds

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