我有一个 Silverlight 控件打包并部署到 SharePoint Web 部件。推送更新后,浏览器无法加载新版本的控件。我正在更新我的 xap 项目的程序集和文件版本,但这似乎并不重要。让浏览器加载新的 xap 的唯一方法是进入并删除临时 Internet 文件。对我来说,在开发过程中,这没关系,但我需要在生产之前找到解决方案。有任何想法吗?
问问题
19961 次
5 回答
38
这与您的浏览器如何处理资源请求有关。Flash 也有类似的问题,并且有几个解决方法。
这是一篇详细介绍问题和可能的解决方案的文章。
我建议做这样的事情:
假设您在 html 中为您的 xap 提供了这个:
<param name="source" value="ClientBin/myApp.xap"/>
我会对其进行版本化,因此每当您进行推送时,您都会更改版本号。例子:
<param name="source" value="ClientBin/myApp.xap?ver=1"/>
于 2009-11-12T14:43:43.547 回答
2
遇到 .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 文件时)。
希望这可以帮助!
于 2013-08-19T07:03:19.373 回答
2
伟大的!甚至在 Windows Phone 开发中工作。
我已经把这条线:
NavigationService.Navigate(new Uri("/Game.xaml?versao="+version, UriKind.RelativeOrAbsolute));
然后覆盖方法OnNavigatedTo
:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string var;
if (NavigationContext.QueryString.TryGetValue("version", out var))
{
...
}
}
于 2011-12-17T03:53:02.073 回答
1
将以下 web.config 放入 ClientBin
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMaxAge="0.00:00:01" cacheControlMode="UseMaxAge"/>
</staticContent>
</system.webServer>
</configuration>
于 2014-02-12T18:55:55.593 回答
0
这里提到的解决方案和其他帖子一直没有帮助我。我最终所做的是将 .xap 和 .svc 文件从我的 Release 版本手动复制到 ClientBin 和 Service 部署文件夹。
于 2019-08-12T09:31:44.703 回答