Force client to update Silverlight XAP file method summary

Source: Internet
Author: User

650) this. width = 650; "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/130445I05-0.png "border =" 0 "height =" 166 "width =" 169 "style =" line-height: 1.8; background-color: rgb (255,255,255); color: rgb (51, 51, 51); font-family: Georgia, 'times New Roman ', Times, san-serif; font-size: 14px; text-align: left; border: 0px; "/>

 

After Silverlight is deployed, the client cannot update the local XAP file. You can only manually clear the browser cache each time before the client can access the latest XAP file. This article describes several methods to force clients to update Silverlight XAP.

 

By default, when a new version of Silverlight application is released, the browser cache queries whether an XAP file with the same name already exists locally and performs simple verification. If the file exists and the verification is the same, the latest XAP file is ignored. We can force the browser to update and download the XAP file in the following ways,

 

Method 1. IIS setting

To force the XAP file to expire after setting IIS properties, the browser will re-download the XAP file as follows:

-Open the IIS manager;

-Open "default website" and find the deployed Silverlight project;

-Find the XAP file in the "ClientBin" directory;

-Go to the XAP properties page and select "HTTP Response Headers ";

650) this. width = 650; "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1304452E1-1.jpg "height =" 101 "width =" 93 "style =" border: 0px; "/>

-In the Actions column, select "Set Common Headers ...";

650) this. width = 650; "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/130445I60-2.jpg "height =" 66 "width =" 204 "style =" border: 0px; "/>

-Select "Expire Web Content-Immediately" and save the settings.

650) this. width = 650; "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/130445F25-3.jpg "height =" 305 "width =" 490 "style =" border: 0px; "/>

After this setting, when the page is refreshed, the Web page content will be forced to expire and the latest XAP file will be downloaded to the local device immediately.

 

Method 2: Force update in dynamic mode

The so-called dynamic force update method uses different XAP file names for each deployment. Each time the browser detects different file names, it will re-download the XAP file.

There are many implementation methods for this method. For example, you can manually add an XAP file parameter, dynamically generate a random parameter, or bind it to the XAP file name based on different versions.

In the following instance code, the date string is used as the parameter of the XAP File Based on the deployment date, which forces the XAP file to be updated,

Code modification static code "<param name =" source "value =" ClientBin/SilverlightApp. xap "/>" is dynamic code. when the project is not in Debug mode, a new XAP file path is generated.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/130445C64-4.gif "alt =" Copy code "style =" border: 0px rgb (221,221,221 ); "/> <object id =" Xaml1 "data =" data: application/x-silverlight-2, "type =" application/x-silverlight-2"
Width = "100%" height = "100%">

<%
String orgSourceValue = @ "ClientBin/SilverlightApp. xap ";
String param;
If (System. Diagnostics. Debugger. IsAttached)
Param = "<param name = \" source \ "value = \" "+ orgSourceValue +" \ "/> ";
Else
{
String xappath = HttpContext. Current. Server. MapPath (@ "") + @ "\" + orgSourceValue;
DateTime xapCreationDate = System. IO. File. GetLastWriteTime (xappath );
Param = "<param name = \" source \ "value = \" "+ orgSourceValue + "? Ignore ="
+ XapCreationDate. ToString () + "\"/> ";
}
Response. Write (param );
%>
<Param name = "onError" value = "onSilverlightError"/> 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/130445C64-4.gif "alt =" Copy code "style =" border: 0px rgb (221,221,221); "/>

 

 

Method 3: automatically generate a local version number to force update the XAP File

This method was proposed by Yang Guo, a netizen under the bodhi tree. The author created a simple local application and used the local application to generate different XAP file name parameters. The principle is the same as method 2 and the implementation method is different.

For details, see the Tutorial "Silverlight: how to solve the xap package (or local cache) download version Update".

 

If you have better methods and suggestions, please leave a message for discussion.

 

Recommended Silverlight 5 books:

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1304452121-6.jpg "width =" 245 "height =" 300 "style =" border: 0px; margin: 0px; padding: 0px; cursor: pointer; "/>


650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1304454N0-7.jpg "width =" 385 "height =" 374 "style =" border: 0px; margin: 0px; padding: 0px; cursor: pointer; "/>
 

Beginning Silverlight 5 in C #, Silverlight5 entry-level book, which details the development basics of Silverlight 5 and introduces the new functions of Silverlight 5 from a simple perspective.

It is suitable for getting started with Silverlight.

Download books

 

 

 

 

You are welcome to join the "Focus on Silverlight" QQ technology group. You are welcome to join in to learn and discuss Silverlight & WPF & Widnows Phone development technology.
22308706 (group 1) super group of 500 people
37891947 (group 2) super group: 500 people
100844510 (group 3) Senior Group: 200 persons
32679922 (group 4) super group: 500 people
23413513 (group 5) Senior Group: 200 persons
32679955 (Group 6) super group: 500 people
88585140 (group 8) super group: 500 people
128043302 (9 Group Enterprise Application Development Recommendation group) Senior Group: 200 people
101364438 (10 groups) super group: 500 people
68435160 (11 Group Enterprise Application Development Recommendation group) super group of 500 people

This article is from the "Kevin Fan" blog, please be sure to keep this source http://kevinfan.blog.51cto.com/1037293/933181

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.