Page view counter

Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

Last post 12-09-2007 2:40 AM by Dougnutz. 13 replies.

Sort Posts:

  • Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    01-29-2007, 8:01 PM
    • Loading...
    • kevyau
    • Joined on 08-01-2006, 4:01 PM
    • Posts 15
    • Points 29

    In latest release of Ajax .NET (1.0), after any post back event (e.g. LinkButton On Click, DropDownList change with AutoPostBack enabled, etc.) an error throw and caught in the Application_Error() method of Global.asax.

    This did not occur in ANY of the previous CTP or RC releases of Atlas/Ajax .NET libraries. Does anyone what is going on and why the new release would throw this error ?  

     
    Error message below:

    Inner Exception
        ---------------
        Type : System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
        Message : Server cannot modify cookies after HTTP headers have been sent.
        Source : System.Web
        Help link :
        ErrorCode : -2147467259
        Data : System.Collections.ListDictionaryInternal
        TargetSite : Void BeforeCookieCollectionChange()
        Stack Trace :    at System.Web.HttpResponse.BeforeCookieCollectionChange()
           at System.Web.HttpCookieCollection.Add(HttpCookie cookie)
           at System.Web.Security.RoleManagerModule.OnLeave(Object source, EventArgs eventArgs)
           at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
           at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

  • Repeater and collections

    01-29-2007, 8:25 PM
    • Loading...
    • happybuddy
    • Joined on 01-23-2007, 11:26 PM
    • Posts 61
    • Points 17

    Hi All,

    Please can someone suggest me a good site or link dealing with repeater control in detail.

    Like - how to use , various events, how to embed controls in repeater and later access them from code. (asp.net and c#)

    Similarly looking for some good links for collections and how to use them (c#)

    thanks a ton,

    Happy buddy

    thanks,
    Buddy
  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    01-29-2007, 10:19 PM
    • Loading...
    • jodywbcb
    • Joined on 03-12-2003, 3:52 PM
    • West Seattle,WA
    • Posts 985
    • Points 4,482

    I think your issue is about where you are setting cookies - but not knowing your setup there I'll point you to a decent link at least and perhaps that will shed light on your situation.  http://www.webdeveloper.com/forum/showthread.php?t=74202

    Hopefully that helps - otherwise would probably need code (specifically where you are setting the cookies if you are handling that in code - which should be the only time that misconfig of cookies should occur...)

     

     

    -- jody
    My Blogs on .Net 2.0 and Ajax
    http://csk.wbcb.com
    http://ArtbyJody.com
  • Re: Repeater and collections

    01-29-2007, 10:21 PM
    • Loading...
    • jodywbcb
    • Joined on 03-12-2003, 3:52 PM
    • West Seattle,WA
    • Posts 985
    • Points 4,482
  • Re: Repeater and collections

    01-30-2007, 5:02 PM
    • Loading...
    • happybuddy
    • Joined on 01-23-2007, 11:26 PM
    • Posts 61
    • Points 17

    Thanks a lot.

    HB 

     

    thanks,
    Buddy
  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    01-30-2007, 5:17 PM
    • Loading...
    • kevyau
    • Joined on 08-01-2006, 4:01 PM
    • Posts 15
    • Points 29

    I understand your point, however, as far as I am aware there is no code we have written which writes/modifies cookies on postback, the code which is writing to the cookie I believe is internal to .NET.

    What is strange is there was no code change, the only change was the update from Ajax .NET RC 1.0 to Ajax .NET 1.0. If I roll back to use Ajax .NET RC 1.0, the this "Server cannot modify cookies after HTTP header have been sent." error does not throw.

  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    02-01-2007, 4:12 PM
    • Loading...
    • kevyau
    • Joined on 08-01-2006, 4:01 PM
    • Posts 15
    • Points 29

    From further investigation, seems that this issue relates to http://forums.asp.net/1/1546340/ShowThread.aspx

    We believe that Response has already been posted back to client browser, before the roleManager (where cacheRolesInCookie="true" from web.config) attempts to modify the client cookie and update the use role.

    The solution would be to set cacheRolesInCookie="false", to correct this error from being thrown.

     

  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    02-01-2007, 4:13 PM
    Answer
    • Loading...
    • kevyau
    • Joined on 08-01-2006, 4:01 PM
    • Posts 15
    • Points 29

    From further investigation, seems that this issue relates to http://forums.asp.net/1/1546340/ShowThread.aspx

    We believe that Response has already been posted back to client browser, before the roleManager (where cacheRolesInCookie="true" from web.config) attempts to modify the client cookie and update the use role.

    The solution would be to set cacheRolesInCookie="false", to correct this error from being thrown.

     

  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    02-02-2007, 4:43 AM
    • Loading...
    • tditiecher
    • Joined on 02-02-2007, 9:39 AM
    • Posts 3
    • Points 2

    Thank you! Setting cacheRolesInCookies="false" did the trick for me.

     

    With kind regards,

    Taco. 

  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    02-02-2007, 5:36 PM
    • Loading...
    • Eilon
    • Joined on 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 866
    • Points 4,828
    • AspNetTeam

    Hi everyone,

    This is now a known issue in AJAX 1.0. We've logged a bug on it and will try to address it in a future release. Thanks for all the feedback!

    - Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    02-11-2007, 11:59 PM
    • Loading...
    • psychodotnet
    • Joined on 09-28-2005, 7:09 AM
    • Posts 1
    • Points 2

    kevyau, thanks for that piece of information. Even though it resolves the issue, there would be a reason why it throws that exception. I will try looking in to the cause, unless its a bug in role manager.

     If you come across any information, kindly post it. Thanks again.

     

    Cheers,

    Sameer.

     

  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    02-28-2007, 2:43 PM
    • Loading...
    • akcapsis
    • Joined on 02-28-2007, 7:35 PM
    • Posts 2
    • Points 2

    I am using asp.net 1.1 and handcoding javascript using the xmlhttprequestobject to do some ajax updating of a dropdownlist etc

    I got the same error message and setting cacheRolesInCookie="false" solved the problem.

    Thanks!

  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    07-05-2007, 4:57 AM
    • Loading...
    • yinix
    • Joined on 05-28-2007, 7:16 AM
    • China.WuXi
    • Posts 1
    • Points 2

    thanks very much,I got the problem too  ,and with setting the cacheRolesInCookie=false,i resovle the problem already!

    I'm studying the asp.net2.0 and asp.net1.1
  • Re: Update Panel throws "Server cannot modify cookies after HTTP headers have been sent." error in new Ajax .NET 1.0 release

    12-09-2007, 2:40 AM
    • Loading...
    • Dougnutz
    • Joined on 10-29-2005, 1:00 AM
    • Posts 5
    • Points 16

    I had the same problem but after some more digging and testing I found that adding a longer timeout to the roles cookie fixed the problem as well, plus you don't take the performance hit for going to your database and getting the user roles information for every request.

     I used cookieTimeout="720" because we validate for 8 hours anyway.

    Hope this helps

     

Page 1 of 1 (14 items)