Silverlight not sending cookies in cross-domain browser requests

馋奶兔 提交于 2019-12-25 04:21:52

问题


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 Fiddler 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!


回答1:


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.




回答2:


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).



来源:https://stackoverflow.com/questions/2072480/silverlight-not-sending-cookies-in-cross-domain-browser-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!