« Previous Next »

Thread: IIS7 Response.Cookies Collection is Empty

Last post 09-08-2009 6:43 PM by Glenn Slayden. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 07-30-2008, 7:56 AM

    IIS7 Response.Cookies Collection is Empty

    On IIS7, the HttpContext.Current.Response.Cookies collection seems to only contain cookies that ASP.NET creates.  So on requests where a Classic ASP page sets 3 cookies, the collection when accessed via an HttpModule (later in the pipeline) is empty.  This seems like a bug, right?


  • 08-01-2008, 1:37 AM In reply to

    • ksingla
    • Top 10 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 845

    Re: IIS7 Response.Cookies Collection is Empty

    Hi CooperNYC,

    Can you pls check if Set-Cookie header is seen correctly in managed module in the later stages of the pipeline? It is possible that Set-Cookie header is not parsed to fill the cookies collection everytime transition from native to managed module happens. I can followup with Asp.Net team to find if this is unexpected behavior.

    Thanks,
    Kj

    Follow me on twitter at http://twitter.com/kjsingla
  • 08-01-2008, 10:15 AM In reply to

    Re: IIS7 Response.Cookies Collection is Empty

    Thanks KJ.  I have tried almost every event in the pipeline with no luck.  I also brought this issue up in the IIS7/ClassicASP forum, so you can see more details about the issue here:

    http://forums.iis.net/t/1150788.aspx

    At this point, it seems like there are two issues:

    1 - The Response.Cookies collection available to managed code is not populated with cookies set by a native handler

    2 - The Response.Headers collection available to managed code seems to overwrite collection items when there are duplicate response headers (instead of concatenating them with a semi-colon).

    Any help you can provide me would be greatly appreciated. 

    Thanks,

    Cooper

  • 08-02-2008, 2:35 PM In reply to

    • ksingla
    • Top 10 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 845

    Re: IIS7 Response.Cookies Collection is Empty

    Hi Cooper,

    1. Can you pls confirm that when you set the Set-Cookie header in native code, Set-Cookie header value as read by Response.Headers in managed code is updated?

    2. I am not sure how Response.Headers behave but can you also try Response.AppendHeader method and see if that gives you what you want.

    Thanks,
    Kj

    Follow me on twitter at http://twitter.com/kjsingla
  • 08-04-2008, 3:46 PM In reply to

    Re: IIS7 Response.Cookies Collection is Empty

    KJ: The test case I am using is a classic ASP page that sets 3 cookies in the HTTP response.  The managed HttpModule is not able to read them later in the pipeline (on the same response...the cookie collection is empty). I'm not sure if setting them from Classic ASP code counts as "Native".

    Response.Headers does seem to work, but I can only see ONE of the cookies (not all three). The Response.AppendHeader method will not work as I need to READ the cookies using the HttpModule, not write additional cookies. 

  • 09-08-2009, 6:43 PM In reply to

    Re: IIS7 Response.Cookies Collection is Empty

    CooperNYC:
    Response.Headers does seem to work, but I can only see ONE of the cookies (not all three). The Response.AppendHeader method will not work as I need to READ the cookies using the HttpModule, not write additional cookies.

    This is exactly the problem I'm having, as I just posted about at http://forums.iis.net/p/1102533/1815781.aspx#1815781 . What's going on with this long-standing issue?

    Note that the hotfix KB932385 does *not* fix this issue, it only ensures that the additional cookies are passed to the client browser, but the server-side Resonse object still does not show them in the Headers property.

    Poking around with the debugger, I couldn't find those cookies (which do end up at the browser) in any internal or public data structure on the server.

Page 1 of 1 (6 items)