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

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

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
stackoverflow.com/questions/1533709/session-id-changing-randomly/1535573#1535573

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

 

Posted on Wednesday, November 25, 2009 6:25 PM asp.net mvc , session , asp.net | 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: GeeksWithBlogs.net