Forcing browsers to reload Silverlight xap after an update

故事扮演 提交于 2019-11-28 22:38:22

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"/>
Dayana Viana

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))
    {
        ...
    }
}

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!

put the following web.config into ClientBin

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!