How To Increase SessionTimeOut - asp.net

I did by writing this line into web.config
<sessionState timeout="540"/>
but My client's Session Expire within 20-40 minute
is there any other way to Increase SessionTimeout for 8-9 hours ?
thanks

Perhaps you could toss something in you global.asax.cs file, to reset the expire. I'd put it in the Application_PreRequestHandlerExecute method / event.
var cookie = Request.Cookies["ASP.NET_SessionId"];
cookie.Expires = DateTime.Now.AddHours(8);
Response.Cookies.Set(cookie);

It's likely that your IIS application pool is recycling. By default it will shut down the worker process after being idle for a certain amount of time.
You could use SQL Server backed session state, or you could increase the worker process idle timeout limit.

Related

Will Session be expired by IdleTimeout of IIS?

I have <sessionState cookieless="false" mode="InProc" timeout="120" /> in my web.config.
But looks like session is expired by IIS Idle timeout which is 20 minutes.
I can't change Idle Timeout manually in IIS, because I have a lot of instances. Can I change it via code or .config files?
Or maybe it's not actually the reason of session expiration?
When these settings are configured, a worker process will shut down after a specified period of inactivity
, from here.
InProc means a session is tracked by a cached record in process memory. Thus, whenever the process exits (with exceptions or not), that session is gone.
Then of course idle timeout of IIS matters in your case, as it can shut down the worker process, and in turn kill the sessions.

Reset Session timeout if the user is active in asp.net

I want to reset the session timeout if the user is active with in the session timeout.
means:
Let an user is logged in to a system whose session time out is 10 min. if the user do some operation with that timeout then the session time out will start when the user is inactive.
if the user is again do so operation then the session time out will be rest.
how to do this one.
please help
Thanks
put follow configuration in your web.config
<sessionState timeout="10" />
MSDN says:
Optional TimeSpan attribute.
Specifies the number of minutes a session can be idle before it is abandoned. The timeout attribute cannot be set to a value that is greater than 525,600 minutes (1 year) for the in-process and state-server modes.
The session timeout configuration setting applies only to ASP.NET pages. Changing the session timeout value does not affect the session time-out for ASP pages. Similarly, changing the session time-out for ASP pages does not affect the session time-out for ASP.NET pages.
The default is 20 minutes.
reference:http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=vs.100%29.aspx
The Server will Automatically reset the Session Time Out , once the user becomes active.
There is not explicit code required to accomplish this..just setting the Session time out would be good enough..
Updated:
Then you should be worth looking at this:
How to stop session timeout after 20minutes in asp.net?
Hope this helps..

Asp.Net (MVC): Which session timeout is what?

I've made one Asp.net MVC website, and I'm very confused between the different timeout settings.
What is the difference between:
SessionState Timeout in web.config:
Application pool timeout
Asp.Net Session timeout property
Which one should I set if I want to have a timout of (say) 6 hours? All of them? Only some?
The application pool timeout is the length of time the site has to be idle for before the application pool will shut down the worker process to release resources. The downside is that when the next visitor comes to the website it takes a long time to restart things so that first request after a shutdown will be quite slow.
IIS7 Application Pool Idle Time-out Settings
The session timeout refers to the session id that a user gets on first request to the site, and when that expires.
I think the ASP one that you've included the screenshot of is for classic ASP, not ASP.NET.
So to increase the session timeout you would use the one in the config file.
There's also a Session state section when you click on the website in IIS that you could possibly use either and there's a timeout at the bottom of the page for it.
But if the value for the application pool timeout is shorter, then your session setting will be irrelevant as the worker process will shut down before the session expires. So you should also change your application pool settings.
Session Time out in IIS 7

session state timeout vs idle timeout

Is the session state timeout setting in the web.config the same as IIS 7 idle timeout setting? If not, which one takes priority? I would like to increase users sessions to a couple of hours.
Make sure your AppPool's idle timeout is GREATER than your session timeout.
Once your AppPool times out, all session data is lost.
Idle timeout is for the application pool as a whole. It kicks in if all the applications linked to the pool have had no activity within the set time.
Session state is per session. This is specifically for a single user session. You can have many sessions occurring at any single time.

Session timeout after 30 minutes in asp.net

I store some information in Session but the Session gets destroyed each time. I don't know why this is happening. I am using IIS7.
This is the setting which I have made:
<sessionState cookieless="AutoDetect" mode="InProc" timeout="120" />
I am storing some information while the user is getting registering but my client complains that when he sits idle for 20-30 minutes the information is lost. I am running application in one custom defined application pool whose idle timeout is 20 minutes (in properties of app pool). Can that be the problem?
Secondly even though I have specified timeout to be 120 minutes but when I click on "Session state" icon in IIS7 it doesn't show 120 minutes anywhere. What can be the problem?
Update: In cookie settings in "Session state" in IIS7 I see timeout as 5 minutes for Asp_NetSessionId. Can that be the culprit?
Well if your application pool is being destroyed after 20 minutes then that would be a problem considering your session is inproc. Increase the timeout of the application pool to be 120 minutes
If you store your session InProc, then every 20 minutes the application will be restarted, and all the sessions are lost.
Run the StateServer service and use
<sessionState mode="StateServer" timeout="120" />
in web.config. Then you don't care how often the app is restarted, you can even upload new version and the sessions will be kept.
Yes, When you specify an idle timeout in AppPool settings, it basically kills your worker process which in turn destroys your session.
You'll see the value under Cookie Settings tab as one of the ways to handle InProc session is via Cookies.

Resources