Pages

Search This Blog

Monday, August 22, 2011

ASP.NET - new session id when refresh the page

Using Visual Studio 2005, dotnet framework 2.0.

Try to get a session id in default.aspx


  public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            txtSessionID.Text = this.Session.SessionID;
        }
    }

when i refresh the page, new session id show. This is weird because it won't happen in Asp.net for dotnet framework 1.1.

To solve the problem, simply add below code in global.asax to register an event handler for the session start event


void Session_Start(Object sender, EventArgs e)
        {

        }


No comments: