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

Asked By Seth Bailey
10-Nov-06 05:28 PM

Hi,

I recently converted a web app from .Net 1.1 to a .Net 2.0.  The app worked fine for months as a 1.1 app but after converting to .Net 2.0 I began seeing the following error in my webserver's event log:

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

The error only occurs intermittently and seems to only occur the first time a particular IP address accesses the page.  If I navigate to the page, get the error, close and reopen the browser and navigate back I no longer get the error.  I do not use any Response.Flushes in the entire app and the app's start page is fairly simple with only a couple session variables being created.  I've tried adding Response.Buffer to the start page but this hasn't helped. 

I googled the error and it seems other people are having this problem as well but I have not found any explanation or solution.  If anyone could shed some light I'd greatly appreciate it.

Thanks,

Seth 

Are you doing anything with Session in the Session_Start  Are you doing anything with Session in the Session_Start

10-Nov-06 05:43 PM

eventhandler in Global.asax?  Are you making any calls to Response.Flush?

Session state id is stored in a cookie. This cookie is a header, and  it has to be
written before any content is written to the output stream. if you do a flush, no headers can be written.   Without looking at your code, the fact that you are saying it seems to happen "the first time" only, that's why my comments.

Not using Response.Flush or Event Handlers  Not using Response.Flush or Event Handlers

10-Nov-06 06:05 PM

Thanks for responding Peter.

No, I am not making any calls to Response.Flush nor am I using any event handlers in the Global.asax.

I read elsewhere that people have been experiencing alot of problems with session loss in .Net 2.0 due to the app domain recycling constantly even though no changes where being made to the app or it's directory.  However, I've built several web apps from scratch using .Net 2.0 and not had this problem, just the ones I convert from .Net 1.1.  Also, it's difficult to test since I can't reliably reproduce the error.

Googling the error showed that quite a few other people have had the same problem after upgrading a working 1.1 app to 2.0 but I can't find anything on MS's site or elsewhere.

Thanks for your time,

Seth

re  re

10-Nov-06 08:08 PM

you lose session state when the application pool is recycled (unless you r using sql server to store your sessions, of course) if that is your problem, and it occurs frequently, then someone missconfigured your webserver as app. pool recycling can be regulated in IIS. i personally think that the error message received sounds like its the app_pool... just a guess, but i'd take a look at the iis settings... try putting the app in a seperate pool for testing, or regulate the recyle settings.

jj

 

Try this  Try this
06-Dec-06 02:32 PM
Make sure you are not doing a Response.Redirect() inside your Session_Start event handler in global.asax.vb.  Response.Redirect() causes the Session to be flushed.  And in Session_Start, the Session is not in a state that is ready to be flushed.
Solution to problem when upgrading from 1.1 to 2.0  Solution to problem when upgrading from 1.1 to 2.0
23-Apr-07 01:17 PM

Hi,

I had no Session_start events or any others, no Response.Redirect and I was experimenting the problem. When I saw this post I realized that the problem is with upgrade because usually you forget to re-compile all the DLLs you made in 1.1 with the 2.0 compiler. So that is what I did and IT WORKED!!!, no more problems!

Hope this helps someone.

Create New Account
help
Visual Studio .net .NET Framework Hi NG, ich habe vor längerer Zeit mit Visual Studio .Net 2003 gearbeitet und überlege momentan auf einen neueren Stand upzudaten. Ein Visual Studio .Net 2008 scheint es nicht zu geben. Habe zumindest mit googeln nichts gefunden. Was
Wise for Visual Studio.NET Wise for Visual Studio.NET By Peter A. Bromberg, Ph.D. To "Print This Page" Link Peter Bromberg Wise for Visual Studio .NET is a total and complete installation development system for creating and editing Windows® Installer
Visual Studio versioning . . . . how to tell? .NET Framework To my knowledge, Visual studio 6 was released in 1998, then Visual Studio .NET 2002 is VS 7, then Visual Studio .NET 2003 is VS 7.1, then Visual
visual studio.net 2003 and Access 2007 database .NET Framework Hi I am currently using Visual Studio.Net 2003 running on Windows Server 2000 operating system. I have used Visual Studio.net 2003 connecting to Access 2002 databases in the pass with great success. Now
Is Visual Studio self-hosting ? .NET Framework Does Microsoft use Visual Studio IDE, Visual Studio Debugger, Visual Studio Linker and Visual Studio compiler for developing Visual Studio ? Or is Visual Studio not