Last post Dec 22, 2010 04:06 PM by richloba
Nov 20, 2006 04:17 AM|doolaard|LINK
Hello, we have a website that was developed under ASP.NET 1.1 and now we want to run it under ASP.NET 2.0. Since we cannot access the original code we placed it in a separate Application Pool and tested the site. Apparently all is oke, however every now
and then the following problem:
Exception message: Session state has created a session id, but cannot save it because the response was already flushed by the application.
I researched the internet and found some possible solutions. One of them is not using Response.Flush(), but since we cannot access the source that isn't option.
Is there any other way to overcome this, please help us out!!
Nov 27, 2006 11:38 AM|CTGuy67|LINK
Dec 18, 2006 01:53 PM|doolaard|LINK
Feb 13, 2007 07:51 AM|softer|LINK
That happens because sometimes (depending on the web.config configuration) the SessionID is not set in the cookie when Session_Srtart 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.
A simple fix would be (in the global.asax file):
void Session_Start(object sender, EventArgs e)
// Code that runs when a new session is started
//Ensure SessionID in order to prevent the folloing exception
//when the Application Pool Recycles
//[HttpException]: Session state has created a session id, but cannot
// save it because the response was already flushed by
string sessionId = Session.SessionID;
response already flushed by
Dec 22, 2010 04:06 PM|RichLoba|LINK
That was interesting. I tried your Session_Start solution however...
When i ran it, it just started an endless loop trying to call the same page over and over until i stopped it.
Thanks for the suggestion, anything is helpful