Does SessionID change with every request in the 2.0 application?

 Posted by Virendradugar on 9/21/2009 | Category: ASP.NET Interview questions | Views: 8069

For any web programmer, its obvious to think and believe that SessionId remains same through out the user session and it was right till asp.net1.1. But in asp.net2.0, this behavior has changed. In the application new sessionid is returned with the response to every request until session objects are not used.

According to MSDN the reason/solution 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.”


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response