Silverlight 跨方案访问 jpeg 被拒绝

发布于 2024-09-29 15:18:38 字数 1095 浏览 1 评论 0原文

我有一个在 https 上运行的 Silverlight4 应用程序,部署到 Azure。除了一个小故障之外,一切正常。我有 jpg 缩略图形式的内容以及带有 .gld 扩展名的关联 zip 文件。我的应用程序应该显示缩略图,并允许用户下载关联的 .gld/zip 文件。

下载工作正常,但是缩略图不会显示在我的用户界面中。我从 ImageFailed 处理程序中收到 AG_E_NETWORK_ERROR。我的 CDN 域的根目录中有一个 clientaccesspolicy.xml 文件。 Fiddler 不显示 Silverlight 访问此文件。

这是 clientaccesspolicy.xml:

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

我对 Silverlight 如何访问可下载内容而不是图像文件感到困惑。如果我将缩略图部署到 azure 中的 blob 存储(在 $root 文件夹中使用相同的 clientaccesspolicy.xml 文件),应用程序确实会拾取缩略图,但如果我可以继续使用 CDN 上已存在的相同文件结构,那将是理想的选择提供者。

如果 Silverlight 应用程序以 http 而不是 https 运行,则一切都会完美显示。

预先感谢您的任何想法!

迈克尔·康纳

I've got a Silverlight4 app that I'm running on https, deployed to Azure. Everything's working except for one small glitch. I've got content in the form of jpg thumbnails and associated zip files with a .gld extension. My app is supposed to display the thumbnails, and allow the users to download the associated .gld/zip files.

The downloads works fine, but, the thumbnails won't display in my UI. I get AG_E_NETWORK_ERROR from my ImageFailed handler. I do have a clientaccesspolicy.xml file in the root of my cdn domain. Fiddler does not show Silverlight accessing this file.

Here's the clientaccesspolicy.xml:

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

I'm stumped as to how Silverlight can access the downloadable content, but not the image files. The app does pick up the thumbnails if I deploy them to blob storage in azure (with the same clientaccesspolicy.xml file in the $root folder), but it would be ideal if I can continue the same file structure that already exists on my cdn provider.

Everything displays perfectly if the Silverlight app runs in http rather than https.

Thanks in advance for any ideas!

Michael Conner

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

Hello爱情风 2024-10-06 15:18:38

感谢您的所有建议 - 已经尝试了所有建议 - 遗憾的是仍然没有运气。不幸的是,位图的 ImageFailed 事件没有提供太多细节。我认为我们可能会遇到图像文件的跨方案限制。

thanks for all the suggestions - have tried them all -- still no luck, sadly. ImageFailed event for bitmap doesn't give much detail, unfortunately. I think we maybe be up against the cross-scheme restriction on image files.

决绝 2024-10-06 15:18:38

你漏掉了一个“>”在第 7 行。

You are missing a ">" in line 7.

春夜浅 2024-10-06 15:18:38

检查fiddler等中使用的uri,检查图像是否使用https

Check the uri used in fiddler or the like, check images are using https

七分※倦醒 2024-10-06 15:18:38

尝试实现更多的调试输出 - 也许像这样:

您可以捕获错误。 BitmapImage、Image、ImageBrush、MultiScaleImage 都有一个 ImageFailed 事件。只需为其设置一个事件处理程序即可。

try to implement more debug output - maybe like this:

You can trap the error. BitmapImage, Image, ImageBrush, MultiScaleImage all have an ImageFailed event. Just set an event handler to it.

你的往事 2024-10-06 15:18:38

或者试试这个:

<allow-from http-request-headers="*">

or try this:

<allow-from http-request-headers="*">
呢古 2024-10-06 15:18:38

我知道这是一个非常古老的问题,但如果有人仍然陷入类似的情况
Silverlight 不允许跨方案访问。您必须两端都有 http 或 https。来自 MSDN:Silverlight 中的 URL 访问限制

  • 如果您想托管您的Silverlight 应用程序并存储您的
    不同服务器上的图片,限制如下:
    如果您无法将图像存储在使用 HTTPS 方案的网站上
    在 HTTP 站点上托管您的应用程序(跨方案)。

  • 您可以将图像存储在跨域网站上,只要
    该跨域站点的方案与
    的方案相同
    托管您的应用程序的站点。

  • 在 Windows 上运行的 Silverlight 应用程序无法将图像存储在
    如果下载了应用程序,则服务器位于本地 Intranet 区域
    来自 Internet 区域(跨区域),除非目标域是
    本地主机。

  • 您可以重定向到另一个图像 URL,只要该 URL 使用
    相同的方案。

I know it's a very old question but if someone is still stuck in a similar situation
Silverlight does not allow cross scheme access. You will have to have either http on both ends or https. From MSDN : URL Access Restrictions in Silverlight

  • If you want to host your Silverlight application and store your
    images on different servers, the restrictions are as follows: You
    cannot store your images on a site that uses the HTTPS scheme if you
    are hosting your application on an HTTP site (cross-scheme).

  • You can store your images on a cross-domain site as long as the
    scheme of that cross-domain site is the same as the scheme of the
    site hosting your application.

  • Silverlight applications running on Windows cannot store images on a
    server in the Local Intranet zone if the application was downloaded
    from the Internet zone (cross-zone), except if the target domain is
    localhost.

  • You can redirect to another image URL as long as the URL uses the
    same scheme.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文