<a href="http://www.cnblogs.com/xtechnet/archive/2011/11/07/2239316.html">http://www.cnblogs.com/xtechnet/archive/2011/11/07/2239316.html</a>
在Index.aspx中注釋掉
<param name="source" value="ClientBin/xxxxxx.xap"/>
增加如下C#代碼:
<%
//2011.11.07 修改 解決xap緩存問題
string strSourceFile = @"ClientBin/xxxxxx.xap";
string param;
if (System.Diagnostics.Debugger.IsAttached)
param = "<param name=\"source\" value=\"" + strSourceFile + "\" />";
else
{
string xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + strSourceFile;
DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
param = "<param name=\"source\" value=\"" + strSourceFile + "?ignore="
+ xapCreationDate.ToString() + "\" />";
}
Response.Write(param);
%>
即可實作當xap有更新的時候立刻通過xap檔案的最後修改時間來判斷是否是新生成的xap,進而控制是讀取緩存中的xap還是下載下傳伺服器上的xap。
參考:http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/#comment-20