开发者

ASP.NET Session ending abruptly

My application's session is ending abruptly and don't see any error being generated in Application_Error in Global.asax. Also, the Session_Start event fires bu开发者_Python百科t not Session_End. It happens after I host the application on a server and does not happen on my dev machine.

The steps to generate this auto exit is to switch between pages that load and display a list of objects (Client, Managers, etc). After about 30-40 seconds of activity, the user is logged out and Login screen is displayed. Any ideas what could be going wrong behind the scenes?

Web.Config has the following settings for session and authentication:

<sessionState timeout="60" mode="InProc" cookieless="false"/>

authentication:

<forms name="XXX.AUTH" loginUrl="~/login.aspx" protection="All" timeout="60" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="~/default.aspx" enableCrossAppRedirects="false"/></authentication>


Are you hosting on a shared hosting environment (i.e. from a hosting provider like GoDaddy)? They may be recycling the IIS worker process every minute or so, in which case you'd lose your session information. You'd have to use some type of out-of-process session state such as a state server or Sql State Server to avoid that.

Here's the MSDN article on it.


Have you checked if the Application Pool for the website is recycling? If that happens the App would be stopped dead in it's tracks. Further many applications run in an application pool, it is possible another app is crashing the pool and taking your app down with it.


You missed changing the session expiry value in you IIS pool properties.


Have you tried specifying the machineKey in your web.config?

<machineKey 
validationKey="random_validation_key" 
decryptionKey="random_decryption_key" 
validation="SHA1" decryption="AES" />

You can generate these keys here: http://aspnetresources.com/tools/machineKey

Also, if you change more than 15 files inside the application (aspx files etc), it will automatically trigger a recompilation of the code and you might lose the session as a result, more info here: http://msdn.microsoft.com/en-us/library/s10awwz0(v=vs.85).aspx


Session is simply a cookie, and each cookie has a time. Maybe you haven't specified the time correctly. Check your web.config file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜