Home » ASP.NET | Bugs | Code

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

17. October 2009 by thebeebs 0 Comments

The session Id is written to a cookie only when Session.SessionId is called, in my current project we don’t use many sessions in the application but they are used by some partial views to pass data around.

Because Session.SessionId is not called before the page is flushed, when the view decides that it needs to save some session information after the page has flushed, it’s too late for the application to write the SessionId to the users cookie collection and so the above error is thrown.

To fix the issue I have ensured that we call Session.SessionID before the page has been flushed by adding the following code into the session start:

 

SessionStart

 

This should fix the issue.

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading