Geeks With Blogs
Rajesh Pillai My experiments with mvc, jquery, wpf, silverlight, sharepoint, tdd and design patterns.

This typical problem is almost faced by all new developer working with

This behaviour is by design as ASP.NET tries to be efficient in storing sessions for users. Remember
unless you store anything in session the session id value keep changing.

If you want to tell ASP.NET that you want it to track user sessions, you can do one of 2 things:

  1. Store something in the session.
  2. Simple handle the Session_Start event in your GLobal.asax. The presence of this method will
    tell ASP.NET to track sessions , even if there is no data in the session..

// NOTE: There is no need to add any thing to session if you are doing this...

public void Session_Start(object sender, EventArgs e)

The related stackoverflow post can be read here

This behavior had caused me much worry in the past :)


Posted on Wednesday, November 25, 2009 6:25 PM mvc , session , | Back to top

Comments on this post: ASP.NET Session Id getting lost

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Rajesh Pillai | Powered by: