Cannot modify cookies after HTTP headers have been sent

  • Thread starter Thread starter gibble
  • Start date Start date
G

gibble

Hi,

I am going crazy. We get a hundred or so of these errors each day and
while the fix would seem obvious, the error does not include a line
number!

--------------------
Process information:
Process ID: 10084
Process name: w3wp.exe

Exception information:
Exception type: HttpException
Exception message: Server cannot modify cookies after HTTP headers
have been sent.

Request information:
Is authenticated: True
Authentication Type: Forms

Thread information:
Thread ID: 15
Is impersonating: False
Stack trace: at System.Web.HttpCookieCollection.Add(HttpCookie
cookie)
at
System.Web.Security.FormsAuthenticationModule.OnAuthenticate(FormsAuthenticationEventArgs
e)
at System.Web.Security.FormsAuthenticationModule.OnEnter(Object
source, EventArgs eventArgs)
at
System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
--------------------


According to the logs, it doesn't matter what browser they are using,
we've had errors from FF, IE6 and IE7, (and AOL users with each of
those browsers as well) The only common thing is if I scanned the
errors properly, they all use XP (NT 5.1) ...but that's not too
surprising.

Any ideas would be EXCELLENT as some users are having issues logging
into the site and I believe these errors to be the culprit.

Thankyou.
 
the cookie is a header, so asp.net raises an error if you change it
after the headers have been sent (as it will have no effect). you have a
page with buffering turned off.

-- bruce (sqlwork.com)
 
I actually believe this issue was resolved by renaming the forms
authentication name in the web.config. I believe during the update
from 1.1 to 2.0 the cookie encryption changed, and since the old
cookie was unable to be read, it couldn't be cleared and recreated the
2.0 way...this renaming seems to have solved the error.

Thankyou though.
 
Apparently, it stopped some of the errors...the once that I got by
email. But some users are still experiencing the problem and the
error shows up in their browser...not caught by our error handling for
some reason.

The one thing I've noticed from the user who intermittently
experiences the error here is that it only happens when clicking on a
link to the site from an email.
 
I stand corrected, I still get errors in my email...just not as many
it seems.

I thought I read somewhere, that it could be something to do with the
session timeout vs the forms authentication cookie timeout?
 
I don't know what page it could be that would have buffering turned
off.

I don't get a line number for where the error occurs...and the site is
over a dozen projects, with 100s of classes in each...the culprit
could be anywhere if it was buffering...

The thing that really bothers me, is this problem wasn't happening
in .NET 1.1, but does in .NET 2.0...and several other issues we've had
that looked like one thing, have turned out to be something else,
related to fundamental changes in defaults/logic/BUGS between 1.1 and
2.0.

I'm going crazy here :-o
 
Back
Top