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:
- Store something in the session.
- 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 :)