A9S6
A9S6

Reputation: 6675

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 but 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>

Upvotes: 2

Views: 3406

Answers (5)

Terry Kernan
Terry Kernan

Reputation: 806

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

Upvotes: 0

Karthik Malla
Karthik Malla

Reputation: 5800

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

Upvotes: 0

Bobby Borszich
Bobby Borszich

Reputation: 11767

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.

Upvotes: 1

Jason
Jason

Reputation: 8640

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.

Upvotes: 3

Saeed Neamati
Saeed Neamati

Reputation: 35822

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

Upvotes: -2

Related Questions