Reputation: 1615
I know that this question has been asked a lot on here but none of the solutions that people offered seemed to really work for me. I am trying to extend the length of time that sessions remain active on my website I tried modifying web.config with:
<sessionState timeout="45"/>
And setting Session.Timeout in the code behind but nether of those worked as intended. I would like to get the sessions to last as long as possible, but as of right now they last about 10 minutes before i start to have issues.
Upvotes: 1
Views: 2120
Reputation: 932
Asp.Net Session Management has two Modes.
InProc
Loss of Session is a common problem in this mode. IIS keep recycling the worker-process after some duration, which causes the loss of Session Data.
Have a look at below link for more informaton on this.
Below CodeProject article has a work-around for this problem.
Prevent Session Timeout in ASP.NET
OutProc
In this mode of Session Management, settings of web.config will work properly. Have a look at below link for more details.
In WebConfig :
<configuration>
<system.web>
<sessionstate timeout="20" />
</system.web>
</configuration>
By default its 20 mins. Change it as per your needs.
Check it in IIS
Open the IIS, click on the Application Pool.
Select the Application pool for your application.
Right Click --> Select Properties. In the Performance tab, Set the idle timeout as your desired minutes for "shutdown worker processes after being idle for ..... minutes".
Restart IIS after that.
Why Session.Timeout is not working for your website
Upvotes: 2
Reputation: 44931
If your session state is setup to be InProc and you have multiple web servers or a web garden, then your session state could easily be lost.
See the MSDN documentation for more details.
Upvotes: 4