Click here to Skip to main content
14,733,890 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
I have an web application where in I have set the session expire time to 160 in Web.Config.

<sessionState mode="InProc" cookieless="false" timeout="160"/>

My problem is that, when the session of logged in user expires, instead of redirection to Login page it gives me runtime error of " Object Reference not set to Instnace of an Object ".
Why is this happening? User should be redirected to Login page if session expires which is not happening.
And please clear me whether the timeout I have set in Web.Config is in milliseconds or minutes.

Any help appreciated.

Make sure you are checking Session expire and redirect to the login page? and timeout is in minutes.
1. Time is in minutes
2. Error is because before using the Session on the page you are not checking if it is null or not
3. Automatic re-directing back to Login page would happen n case of Forms Authentication. (if you have windows authentication then you need to write code for it when you find that the session is lost.)
Lokesh Zende 25-Nov-10 2:05am
Hi Sandip,
I have used Form authentication only.
This is what I have in Web.Config :

<authentication mode="Forms">
<forms loginUrl="~/Default.aspx" name="XESS" timeout="120" />

Sandeep Mewara 25-Nov-10 2:14am
Well, as you can see... you have given your forms authentication timeout to be 120min and session defualt timeout is 20 min...

Thus, when session expires, it throws an error (as you must have not checked for valid value)
Lokesh Zende 2-Dec-10 23:38pm
I am still not clear with you.
Colud you please tell me what exactly should I do?
Sandeep Mewara 3-Dec-10 4:50am
Well, in that case, have a look at this article:
Sandeep Mewara 3-Dec-10 4:50am
Session timeout & forms authentication timeout are two different things. Both configured differently in web.config file.
You need to provide a bit more information in order to help you with
" Object Reference not set to Instance of an Object " exception.

The timeout is in minutes.

Check this link[^] for general info on session.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900