更新后强制浏览器重新加载 Silverlight xap

发布于 2024-08-11 04:05:32 字数 189 浏览 13 评论 0原文

我有一个 Silverlight 控件,已打包并部署到 SharePoint Web 部件。推送更新后,浏览器加载新版本的控件时遇到问题。我正在更新我的 xap 项目的程序集和文件版本,但这似乎并不重要。让浏览器加载新 xap 的唯一方法是进入并删除临时 Internet 文件。对我来说,在开发过程中,这没问题,但我需要在投入生产之前找到解决方案。有什么想法吗?

I have a Silverlight control packaged up and deployed to a SharePoint web part. I'm having trouble with the browser loading new versions of the control after I push an update. I'm updating the assembly and file version of my xap project, but it doesn't seem to matter. The only way to get the browser to load the new xap is to go in and delete temporary Internet files. For me, during development, that's OK, but I'll need to find a solution before it's time for production. Any ideas?

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

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

发布评论

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

评论(5

夏末的微笑 2024-08-18 04:05:33

这与您的浏览器处理资源请求的方式有关。 Flash 也有类似的问题,并且有一些解决方法。

这是一篇文章,详细介绍了该问题和可能的解决方案。

我建议做这样的事情:

假设你的 html 中的 xap 有这个:

<param name="source" value="ClientBin/myApp.xap"/>

我会对它进行版本控制,因此每当你执行推送时,你都会更改版本号。例子:

<param name="source" value="ClientBin/myApp.xap?ver=1"/>

This has to do with how your browser handles resource requests. Flash has similar issues and there are a couple workarounds.

Here's an article that details the issue and possible solutions.

I would suggest doing something like this:

Say you have this for your xap in your html:

<param name="source" value="ClientBin/myApp.xap"/>

I would version it so whenever you do a push you change the version number. Example:

<param name="source" value="ClientBin/myApp.xap?ver=1"/>
把人绕傻吧 2024-08-18 04:05:33

伟大的!甚至还从事 Windows Phone 开发工作。

我添加了以下行:

NavigationService.Navigate(new Uri("/Game.xaml?versao="+version, UriKind.RelativeOrAbsolute));

然后重写方法 OnNavigedTo

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    string var;
    if (NavigationContext.QueryString.TryGetValue("version", out var))
    {
        ...
    }
}

Great! Worked even in Windows Phone development.

I've put the line:

NavigationService.Navigate(new Uri("/Game.xaml?versao="+version, UriKind.RelativeOrAbsolute));

And then Override the method OnNavigatedTo:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    string var;
    if (NavigationContext.QueryString.TryGetValue("version", out var))
    {
        ...
    }
}
疯到世界奔溃 2024-08-18 04:05:33

遇到 .XAP 缓存的情况并不少见,这意味着每次部署新版本的 Silverlight 应用程序时,浏览器都不会下载更新的 .XAP 文件。

一种解决方案是更改 IIS 属性。您可以按照以下步骤为您的 .XAP 文件打开“启用内容过期 HTTP 标头”选项:

Open IIS Manager
Go to “Default Web Site” and find web site for your Silverlight project.
Find the .XAP file under ClientBin.
Go to the properties page of the .XAP file, on HTTP Headers Tab, Turn on “Enable Content Expiration”, click the “Expire Immediately” radio button.
Save the changes.

这样,当您刷新页面时,将下载最新的 .XAP(仅当有最新的 .XAP 文件时),而无需关闭浏览器。

希望这有帮助!

t’s not very uncommon to run into .XAP caching, which means that every time you deploy a new version of the Silverlight application, the browser does not download the updated .XAP file.

One solution could be to change the IIS properties. You can turn the “Enable Content Expiration HTTP header” option on for your .XAP file by following these step:

Open IIS Manager
Go to “Default Web Site” and find web site for your Silverlight project.
Find the .XAP file under ClientBin.
Go to the properties page of the .XAP file, on HTTP Headers Tab, Turn on “Enable Content Expiration”, click the “Expire Immediately” radio button.
Save the changes.

This way the latest .XAP (only if there is a latest .XAP file) will get downloaded when you refresh your page without having to close the browser.

Hope this helps!

疯到世界奔溃 2024-08-18 04:05:33

将以下 web.config 放入 ClientBin

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMaxAge="0.00:00:01" cacheControlMode="UseMaxAge"/>
    </staticContent>
  </system.webServer>
</configuration>

put the following web.config into ClientBin

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMaxAge="0.00:00:01" cacheControlMode="UseMaxAge"/>
    </staticContent>
  </system.webServer>
</configuration>
┈┾☆殇 2024-08-18 04:05:33

这里提到的解决方案和其他帖子始终没有帮助我。
我最终所做的是将 .xap 和 .svc 文件从我的 Release 版本手动复制到 ClientBin 和 Service 部署文件夹中。

The solutions mentioned here and other posts did not help me, consistently.
What I did in the end was manually copy the .xap and the .svc files from my Release build to the ClientBin and Service deployment folders, respectively.

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