Azure上的Silverlight跨域问题

本文关键字:问题 Silverlight 上的 Azure | 更新日期: 2023-09-27 18:09:47

我的解决方案中有3个项目。一个是Silverlight项目,一个是承载Silverlight并提供一些WCF服务的Web项目,第三个是包含一些WCF服务的Web项目,将由Silverlight客户端访问。

在我的客户端机器工作正常,在生产服务器。在我目前的生产服务器中,我有两个服务器Web应用程序托管在同一域中,作为不同的Web应用程序。

问题是,现在我们正试图将整个东西迁移到azure。我创建了两个网站,每个WebApp一个。所以我有,比方说,以下地址:MySLHostWebApp.azuresites.net和MyWCFServices.azuresites.net。

silverlight应用程序正在运行,并且正在正确访问MySLHostWebApp.azuresites.net上的服务,但是当silverlight客户端试图访问MyWCFServices.azuresites.net时,我有以下错误:

An error occurred while trying to make a request to URI 
'http://MyWCFServices.azuresites.net/MyService.svc'. This could be due to 
attempting to access a service in a cross-domain way without a proper cross-
domain policy in place, or a policy that is unsuitable for SOAP services. You 
may need to contact the owner of the service to publish a cross-domain policy 
file and to ensure it allows SOAP-related HTTP headers to be sent. This error 
may also be caused by using internal types in the web service proxy without 
using the InternalsVisibleToAttribute attribute. Please see the inner exception 
for more details.

在搜索了web后,我发现我必须在我的WCF服务中包含一个clientaccessppolicy .xml文件,以允许跨域调用,但我的服务已经有这个文件,具有以下内容:

<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-methods="*">
        <domain uri="*" />
      </allow-from>
      <grant-to>
        <resource include-subpaths="true" path="/"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

有谁知道是什么问题吗?

Azure上的Silverlight跨域问题

我找到问题了。我本想把这个问题删掉,但我宁愿把解决办法留在这里,因为其他人也可能有同样的问题。

问题是MyWCFServices.azuresites.net在azure中错误地配置为需要AD身份验证。一旦我删除了这个要求,它就可以正常工作了。我仍然不知道为什么认为不相关的错误信息。