What's causing “Session state has created a session id, but cannot save it because the response was

Posted by mike nelson on Stack Overflow See other posts from Stack Overflow or by mike nelson
Published on 2009-05-25T00:22:36Z Indexed on 2010/03/16 12:06 UTC
Read the original article Hit count: 224

I'm getting this fault intermittently.

I found this link which summarises fairly well what I was able to find on the Google: http://www.wacdesigns.com/2009/02/03/session-state-has-created-a-session-id-but-cannot-save-it-because-the-response-was-already-flushed-by-the-application/

Basically it says you can try setting the web config setting DisplayWhenNewSession, or try kicking the session state thing into life by getting the Session.SessionID in the Session_OnStart.

But does anyone:

a) have an explanation for this

or even better, b) have a tried and tested fix

I realise that I can't flush the response after doing anything that would affect the http response header. If I did this it would cause an error every time but this is intermittent. The SessionID should surely be created by ASP.NET at the beginning of the page response automatically, before anything in the ASPX page or the Page_Load (which is where all my flushes are called).

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about session-state