What to do when session is getting expired frequently


I have one application built in ASP.NET.

On login page I have taken user id and stored it in one Session Variable Session["user_id"].

I am using it throught the application as we want to know that which user has added that particular record.

We are storing added by field in every table of database.
Many users get logged in in the system at a particular time.

Sometimes the session gets expired automatically and we does not get the Session["user_id"].

It gives the following error and comes to the login page as we have redirected to login page when session expires.

System.NullReferenceException: Object reference not set to an instance of an object.

We have given Session TimeOut 120 minutes in web.config but session is getting expired frequently.

Can any one tell what can I do so that Session does not get expire before 120 minutes.

Help is greatly appreciated.

Thanks and Regards,
Rahul Rathi


  • Can you please give more information about this.
    is it in production server or in your local IIS?
    if in production server it is web farm or garden?

    which session state ytou are mentioned in web.config?
    inproc or some other

  • Hi
    we are using IIS.
    Session state in web.config is "InProc".

  • This post has been deleted.
  • What version of IIS you are using and what version of .net you are using for development.

    Set the session state in web server IIS 6.0.

    From VS2008 onwards there is an enhancement like the session timeout setting in web server IIS overrides the session timeout setting in web.config. This is basically implemented for security purpose

    Please double check !!

    We make a living by what we get, but we make a life by what we give.
    ::: Winston Churchill :::
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!