Wednesday, April 22, 2009

SessionID changes after each post back or each refresh of page.

SessionID changes after each post back or each refresh of page.

if you have problem of changing sessionID (Session.SessionID) on each post back or refresh.
you can add Global.asax file In your Application.

Once i Got this problem.i dont know why this happning. But i found Solution
by help of my friend.

you can Add Global.asax in your application folder

OR

You can Declare dummy session in Your Page Load event handler.
eg.

Session["Dummy"]="";

if you find and other solution or reason for this problem please leave
a comment.

Thanks.

3 comments:

  1. Thanks, this helped my problem!

    ReplyDelete
  2. You will find this problem/issue only in ASP.NET 2.0 or later versions. The reason is:
    "When using cookie-based session state, ASP.NET does not allocate storage for session data until the Session object is used. As a result, 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."

    ReplyDelete
  3. i implement visitors count functionality in my web site. I used Session_Start() in Global file.
    Count gets incremented each time that page refreshes.
    Whats soln for that.

    ReplyDelete

Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author