Session state has created a session id, but cannot save it because the response was already flushed by the application.

This happens because sometimes (depending on the web.config configuration) the SessionID is not set in the cookie when Session_Start event executes in the global asax.

You encounter this error because at somepoint in the pagelifecycle a variable is set in the session. after the request ends, ASP.NET tries to set the SessionID too, but if the Request was flused 
(eg. this can be done by Response.Write or AJAX itself flushes the response) this exception will be thrown.

Add following code in the global.asax file:

      void Session_Start(object sender, EventArgs e) 
          string sessionId = Session.SessionID;
 //This code run when new session is started.

Posted in |


Post a Comment