I have a web page that works fine as long as the pc does not go into sleep mode. The page uses some session variables and if those session variables are not available on the load or postback the page redirects to the site's main page. Oddly enough the
page displays correctly when you come back from sleep mode, but as soon as you try to use any of the page functions the page gets redirected to the site's main page. The question I have is do you lose your session variables once the pc goes into sleep mode
and if so is there a work around? Is there anything else I should look at to diagnose the problem?
Session variables generally last only about 20 minutes or so after the last activity. When accessing session variables, I always use methods that enable me to make a call to check the session variable (such as an object with static properties) that I can
get/set the sessoin variables easily and handle things if the session variable is null.
Session variables are stored in memory, which makes them very volatile. Since memory is a valuable resource, the web server does whatever it can to ensure that memory is always available. This includes garbage collecting by way of destroying sessions once
the user has been inactive. On top of that though, IIS will release the application itself after a period of inactivity and then recompile and reload the app upon the next request.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
Marked as answer by Mark - MSFT on Jan 28, 2013 01:13 AM
Would I be better using a cookie rather then a session variable in this case?
Cookies save information on client side (in browser) while sessions keep data in server side. So any information you save at the client side have the security risk of exposing to the end user. Also, cookies will be there until user clears it from the browser
while session will be there only for a particualar session (hence the name session).
tcl4p
Member
26 Points
85 Posts
web page crashes after sleep mode
Jan 20, 2013 02:48 PM|LINK
I have a web page that works fine as long as the pc does not go into sleep mode. The page uses some session variables and if those session variables are not available on the load or postback the page redirects to the site's main page. Oddly enough the page displays correctly when you come back from sleep mode, but as soon as you try to use any of the page functions the page gets redirected to the site's main page. The question I have is do you lose your session variables once the pc goes into sleep mode and if so is there a work around? Is there anything else I should look at to diagnose the problem?
Thanks,
Tom
stmarti
Contributor
5083 Points
1061 Posts
Re: web page crashes after sleep mode
Jan 20, 2013 03:14 PM|LINK
I think your session is simple timed out. Increase the session timeout in the web.config.
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: web page crashes after sleep mode
Jan 20, 2013 03:54 PM|LINK
Besides Session, I think your problem is also related to Application Pool idle timeout. You can configure your app pool idl timeout by going through the steps mentioned in below link.
http://technet.microsoft.com/en-us/library/cc771956(v=ws.10).aspx
or you can even disable app pool with this link
http://forums.iis.net/t/1170618.aspx/1
markfitzme
All-Star
15413 Points
2368 Posts
Re: web page crashes after sleep mode
Jan 20, 2013 04:23 PM|LINK
Session variables generally last only about 20 minutes or so after the last activity. When accessing session variables, I always use methods that enable me to make a call to check the session variable (such as an object with static properties) that I can get/set the sessoin variables easily and handle things if the session variable is null.
Session variables are stored in memory, which makes them very volatile. Since memory is a valuable resource, the web server does whatever it can to ensure that memory is always available. This includes garbage collecting by way of destroying sessions once the user has been inactive. On top of that though, IIS will release the application itself after a period of inactivity and then recompile and reload the app upon the next request.
tcl4p
Member
26 Points
85 Posts
Re: web page crashes after sleep mode
Jan 20, 2013 07:06 PM|LINK
Thanks for the information. Would I be better using a cookie rather then a session variable in this case? Any advantage of one over the other?
Ruchira
All-Star
44410 Points
7196 Posts
MVP
Re: web page crashes after sleep mode
Jan 21, 2013 09:34 AM|LINK
Hello,
Cookies save information on client side (in browser) while sessions keep data in server side. So any information you save at the client side have the security risk of exposing to the end user. Also, cookies will be there until user clears it from the browser while session will be there only for a particualar session (hence the name session).
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.