search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

View Other Visual Studio .NET Posts   Ask New Question 
Session state has created a session id, but cannot save it because the response was already flushed by the application.
Seth Bailey posted at Friday, November 10, 2006 5: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
Peter Bromberg replied to Seth Bailey at Friday, November 10, 2006 5: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
Seth Bailey replied to Peter Bromberg at Friday, November 10, 2006 6: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
Jeremiah Jacobs replied to Seth Bailey at Friday, November 10, 2006 8: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
David Weprin replied to Seth Bailey at Wednesday, December 06, 2006 2: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
Francisco Gutierrez replied to Seth Bailey at Monday, April 23, 2007 1: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.