Vishal Suthar
Vishal Suthar

Reputation: 17193

I am getting "Object reference not set to an instance of an object."

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..?

Upvotes: 0

Views: 3927

Answers (1)

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.

Upvotes: 2

Related Questions