Wednesday, December 26, 2012

Why session id changes every time in ASP.NET?

Why session id changes every time in ASP.NET?
protected void Session_Start(Object sender, EventArgs e) 
{
    Session["init"] = 0;
}
http://msdn.microsoft.com/en-ca/library/system.web.sessionstate.httpsessionstate.sessionid.aspx
a new session ID is generated for each page request until the session object is accessed. If your application requires a static session ID for the entire session, you can either implement the Session_Start method in the application's Global.asax file and store data in the Session object to fix the session ID, or you can use code in another part of your application to explicitly store data in the Session object.