Silverlight OData Services Sending Multiple Cookies


  • I'm trying to pass multiple cookies to an OData service from a Silverlight application. I'm subclassing a DataServiceContext and wiring up to the SendingRequest event and doing the following:

            protected virtual void OnDataSourceSendingRequest(object sender, SendingRequestEventArgs e)

    CookieContainer cookieContainer = new CookieContainer();
    foreach (var cookieContent in _cookies)
    Cookie cookie = new Cookie(cookieContent.Key, cookieContent.Value.Value);

    .Add(new Uri("http://localhost", UriKind.Absolute), cookie);

    var cookieHeader = cookieContainer.GetCookieHeader(new Uri("http://localhost", UriKind.Absolute));
    .RequestHeaders["Cookie"] = cookieHeader;


    If you look at the headers using Fiddler, only the first Cookie is propagated to the request. Is this a bug or am I doing something wrong?

    Monday, April 02, 2012 8:32 AM

All replies

  • I repro'd your issue and was able to fix it by getting the cookieHeader string to delimit the cookies with a comma instead of a semicolon, which is what the GetCookieHeader method seems to generate by default. 

    I don't really know anything about this, but looking at, I think there are multiple specifications for how the header is written. Might have something to do with that.  I can investigate more if that would be helpful, but that might be enough to get you rolling again.


    Friday, April 13, 2012 12:08 AM
  • Ian,

    Thanks for the reply. Interesting. I'll have a fiddle and see if comma-delimiting works for me. 

    Friday, April 13, 2012 7:19 AM
  • Any luck with the comma-delimiting?


    Monday, April 16, 2012 6:37 PM