0

I am getting the Object reference not set to an instance of an object. error frequently even if I have tried increasing Session Timeout = 1440 in the web.config file.

This happens on the Session["company_id"] because I am using this session again and again in most of the pages.

I know that the Session["company_id"] is getting expired but Is there a way to increase the time of expiration..?

7
  • 2
    May be the Session["company_id"] is null or empty i think, and you are trying to use it. Check the value of the session before you gonna use it. Commented Mar 31, 2012 at 7:14
  • Yes..that I can do but is there a way such that it may not expired for a long duration.. Commented Mar 31, 2012 at 7:15
  • 2
    Check the Timeout duration from the start time and when ever its getting less than 10, regenerate the timeout by checking it through a seperate thread. Commented Mar 31, 2012 at 7:17
  • Can you implement it because I am not able to get it..? Commented Mar 31, 2012 at 7:18
  • Objects don't get expired from the session. Isn't the Session itself null? Did you disable the session for certain pages? Commented Mar 31, 2012 at 7:27

1 Answer 1

2

The Object reference not set to an instance of an object exception will comes only when a null or empty object is tried to use. Inorder to make the session not to be expired for a long time, you should follow two steps.

  1. Keep a continous eye on the Session Timeout.
  2. Redirect the session when its about to expire.

The Base Page for Detecting Sessions will explain you every thing you need to do, please refer it once.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.