Silverlight not sending cookies in cross-domain browser requests
I have a Silverlight 3 control that makes a cross-domain HTTP request to http:// somedomain/. I am using the browser HTTP stack to make this request. A proper clientaccesspolicy.xml on somedomain is in place.
My browser has a set of cookies for somedomain and I want these to by used when said HTTP request is made.
When my Silverlight control is loaded from http:// localhost/, however, none of my cookies seem to be transmitted (I am using Fidd开发者_Python百科ler to trace HTTP traffic)!
When I upload the xap to http:// somedomain/ though and load it from there (so that the HTTP request is not cross-domain), I see that all of my browser/IE cookies for somedomain are transmitted and everything is fine.
Is this intended behavior? I have checked MSDN and it says that browser cookies are always transmitted, regardless of whether the request is cross-domain or not.
Thanks in advance!
Spent hours with a similar problem. Turns out the site wasn't in the Trusted Sites. This seemed to prevent the Browser WebRequest that the Silverlight SharePoint ClientContext uses to send the required cookies (FedAuth in my case).
Actually when using the browser HTTP stack Silverlight doesn't have a great deal of control over how the cookies are handled. It leaves that up the settings the user has configured in the browser.
It might be worth you editing your HOSTS file and placing mapping your IP address to a name like "myhost.mydomain.com" (yes you can just pick what ever you like). Now visit your local site using this host name.
Under IE localhost is placed in a different zone to that of the wider internet and you may be tripping over some wierd limitations when cross from one zone to anotheer. Using a FQDN as above should place your site in the internet zone. This will at least eliminate zone issues as a source of this problem.
Another test would be use Firefox instead.
精彩评论