Flash/Flex crossdomain.xml 帮助
我试图弄清楚如何正确设置我的跨域文件。这是我到目前为止所拥有的:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all" />
<allow-access-from domain="contoso.com"/>
<allow-access-from domain="*.contoso.com"/>
</cross-domain-policy>
Flex 应用程序配置为访问 asp.net web 服务,
http://www.contoso.com/webservice.asmx
当我导航到:
`http://www.contoso.com/flexapp.html`
应用程序加载并工作正常。但是,当我导航到:
`http://contoso.com/flexapp.html`
由于沙箱安全错误,Flex 应用程序无法与 Web 服务通信。有人知道我需要如何配置 crossdomain.xml 文件,以便用户不必记住在网址中包含“www”吗?
感谢您的帮助。
I am trying to figure out how to properly setup my crossdomain file. Here is what I have so far:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all" />
<allow-access-from domain="contoso.com"/>
<allow-access-from domain="*.contoso.com"/>
</cross-domain-policy>
The flex app is configured to access a asp.net webservice at
http://www.contoso.com/webservice.asmx
When I navigate to:
`http://www.contoso.com/flexapp.html`
the application loads and works just fine. However, when I navigate to:
`http://contoso.com/flexapp.html`
the flex app fails to communicate with the webservice due to a sandbox security error. Any body know how I need to configure my crossdomain.xml file so that users do not have to remember to include "www" in the url?
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通常为重定向到 www 的非 www 域名设置 301(永久移动)重定向。我认为这是一种很常见的做法。另一种选择是在 Flex 应用程序中使用相对路径(尽管使用 WSDL 会更困难)。如果您必须发出跨域请求,那么您还需要指定 主策略。另一种替代方法是将 Web 服务放在 ws.contoso.com 上,并制定允许来自 contoso.com 和 www 的请求的跨域策略。 contoso.com。
I usually setup a 301 (permanently moved) redirect for me non-www domain names that redirect to www. I think that is a pretty common practice. Another option is to use relative paths in your Flex app (although that's harder with WSDLs. If you must make the crossdomain request then you will also need to specify the master policy. Another alternative would be to put the web services on ws.contoso.com and have a crossdomain policy that allows requests from contoso.com and www.contoso.com.
“*.contoso.com”
应该可以工作。你尝试明确指定它吗?编辑:为什么你首先需要一个策略文件?两者都在同一个域中,对吗?将加载 url 更改为相对路径。
"*.contoso.com"
should work. Did u try specifying it explicitly?EDIT: why do u need a policy file here in the first place? Both are in the same domain, right? change the load url to a relative path.