Forcing browsers to reload Silverlight xap after an update
Asked Answered
H

5

30

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?

Hugibert answered 12/11, 2009 at 14:39 Comment(0)
W
38

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"/>
Worthy answered 12/11, 2009 at 14:43 Comment(4)
Does that value associate back to the assembly version (i.e., 1.0.0.0)?Hugibert
@Chris no it's completely made up. You can put anything there, as long as you change it whenever you want to push the changes down to the client. Best Practice, though, might be to keep it in line with your versioning.Worthy
This didn't work for me. I solved it using this: #2282419Positivism
I added the setting of this querystring value in the host.aspx file to our deployment script. I never have to think of it again and it worked like a charm! Note that we already had the pragma nocache set but it was not working for all of our customers.Adolphus
A
2

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))
    {
        ...
    }
}
Allele answered 17/12, 2011 at 3:53 Comment(0)
C
2

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!

Crinose answered 19/8, 2013 at 7:3 Comment(0)
A
1

put the following web.config into ClientBin

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMaxAge="0.00:00:01" cacheControlMode="UseMaxAge"/>
    </staticContent>
  </system.webServer>
</configuration>
Aggappora answered 12/2, 2014 at 18:55 Comment(0)
F
0

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.

Florinda answered 12/8, 2019 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.