在同一个域中工作时Silverlight跨域错误

问题描述 投票:0回答:2

我正在尝试使用ssl和silverlight客户端应用程序访问.asmx Web服务,我已经做过的事情:1。我有一个crossdomain.xml(只需要clientaccesspolicy.xml或crossdomain.xml)。 2.我在serviceReferences.ClientConfig文件中有标记。 3.当我使用ssl(“https:// ...”)调用webservice时,我得到了跨域错误,当我将访问点更改为没有ssl时(“http:// ...”)它工作正常! 4.我使用和不使用ssl浏览了web服务地址,boath工作。

如何在同一个域工作时遇到跨域错误?...

silverlight ssl dns
2个回答
1
投票

确保您在clientaccesspolicy.xaml中有适当的SSL输入。你可以看看msdn http://msdn.microsoft.com/en-us/library/cc645032%28v=vs.95%29.aspx。但是,如果您的Web服务托管在与Silverlight应用程序相同的Web应用程序中,则可以在客户端的端点配置(.ClientConfig)中传递相对路径到WS,并且不需要crossdomain / clientaccesspolicy文件。例如,不使用address =“http://localhost/Services/ExampleService.asmx”,而是使用类似address =“../ Services / ExampleService.asmx”(取决于XAP文件所在的文件夹)。


0
投票
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
        <domain uri="http://*" />
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

像这样。由于不明显的原因,<domain uri="http://*" />实际上有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.