Posted: 8/20/2011
I am using a session variable on a couple different pages within my application. If my site sits idle for a period of time I get a runtime error when I click on anything. From what I have read I think it is because I need to do a "proper" null check. Is this done in the global.aspax within the Session_start? or just on the pages where I am using the Session variable?
thanks in advance
Posted: 8/22/2011
Hi Mike,
You should check if this value is null at the page where you use it.
Best Regards,
Gjorgji
Another option is to redirect the end users to your login page if Session times out.. You can find more examples at google:http://www.google.com/#sclient=psy&hl=en&source=hp&q=display+if+sessions+time+out+asp+net&pbx=1&oq=display+if+sessions+time+out+asp+net&aq=f&aqi=&aql=&gs_sm=e&gs_upl=7l5727l2l5810l28l19l0l0l0l1l1526l16482l3-1.6-8.7.1l17l0&bav=on.2,or.r_gc.r_pw.&fp=165bfefa6b75e1a2&biw=1280&bih=879
Posted: 8/24/2011
If you want to increase the time before the session is lost then change the timeout property for the SessionState node in the web.config.
I had a client who hated the timeout, so we lengthened the timeout to an hour.
Another method would be to implement a timer in your project that performs a postback periodically (e.g, every 19 minutes if the timeout is 20 minutes). This way the session would not be lost.
However, if these examples are not relevant to your situation then you should catch the timeout error and take the user to an error page that lets them know their session timed out.
Posted: 9/29/2011
You can set the Condition for the Session Expire ...If the Session is Null then Redirect the Page to the Index Page..Then if your Session may be Expire then Your page automatically redirect to the index page...
Posted: 12/1/2011
In each page page load event check the session is null if the session is null then redirect the page to login page.
protected void Page_Load(object sender, EventArgs e){
if (Session["Session_Name"] == null) { Response.Redirect("Login.aspx"); }
//
}