Silverlight不会在跨网域浏览器请求中发送Cookie [英] Silverlight not sending cookies in cross-domain browser requests

查看:515
本文介绍了Silverlight不会在跨网域浏览器请求中发送Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight 3控件,使跨域HTTP请求到http:// somedomain /。我使用浏览器的HTTP栈来做这个请求。



我的浏览器有一组用于somedomain的cookie,而我想要这些在所述HTTP请求时使用。 / p>

然而,当我的Silverlight控件从http:// localhost /加载时,我的cookie似乎没有被传输(我使用Fiddler跟踪HTTP流量) / p>

当我将xap上传到http:// somedomain /虽然并从那里加载它(这样HTTP请求不是跨域),我看到所有



这是想要的行为吗?我已经检查MSDN,它说,浏览器cookie总是传输,无论是否是跨域的请求。



提前感谢!

解决方案

实际上当使用浏览器HTTP堆栈时Silverlight对cookies的处理方式没有太多的控制。



这可能值得编辑您的HOSTS文件,并将您的IP地址映射到一个名称,如myhost .mydomain.com(是的,你可以选择你喜欢什么)。现在使用此主机名访问您的本地网站。



在IE本地主机下放置在与更宽的互联网不同的区域,并且您可能会跳过某些更加有限的限制,从一个区域交叉到anotheer。使用上面的FQDN应该将您的网站放在互联网区域。这将至少消除区域问题作为此问题的根源。



另一个测试将使用Firefox。


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!

解决方案

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.

这篇关于Silverlight不会在跨网域浏览器请求中发送Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆