我有一个 Silverlight 控件打包并部署到 SharePoint web 部件中。在推送更新后,我遇到了浏览器无法加载新版本控件的问题。我已经更新了 xap 项目的程序集和文件版本,但似乎没有用。唯一让浏览器加载新 xap 的方法是进入并删除临时 Internet 文件。对我来说,在开发期间这样做还可以,但在生产环境之前需要找到解决办法。有什么想法吗?
我有一个 Silverlight 控件打包并部署到 SharePoint web 部件中。在推送更新后,我遇到了浏览器无法加载新版本控件的问题。我已经更新了 xap 项目的程序集和文件版本,但似乎没有用。唯一让浏览器加载新 xap 的方法是进入并删除临时 Internet 文件。对我来说,在开发期间这样做还可以,但在生产环境之前需要找到解决办法。有什么想法吗?
<param name="source" value="ClientBin/myApp.xap"/>
我建议你对它进行版本控制,这样每次推送时都会更改版本号。例如:
<param name="source" value="ClientBin/myApp.xap?ver=1"/>
遇到.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.
太好了!即使在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))
{
...
}
}
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMaxAge="0.00:00:01" cacheControlMode="UseMaxAge"/>
</staticContent>
</system.webServer>
</configuration>