SilverLight应用部署问题之客户端自动获取最新版本问题

通过检查xap文件的创建时间,来决定是否使用缓存,如果创建时间改变,那么将下载最近修改的服务器文件,如果时间没变,将使用IE上次的缓存文件。

修改启动文件default.aspx的内容为如下(检查文件开头是否包含<%@ Page Language="C#" AutoEventWireup="true" %>):
 <%
     string strSourceFile = @"ClientBin/PatientCare.xap";
     string param;
     string initparams;
     if (System.Diagnostics.Debugger.IsAttached)
     {
         param = "<param name=\"source\" value=\"" + strSourceFile + "\" />";
         initparams = "<param name=\"InitParams\" value=\"DebugHost=true\" />";
     }
     else
     {
         string xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + strSourceFile;
         DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
         param = "<param name=\"source\" value=\"" + strSourceFile + "?ignore="
                 + xapCreationDate.ToString() + "\" />";
         initparams = "<param name=\"InitParams\" value=\"" + @"SvcBaseAddress=http://192.168.8.37/PatientCareService" + "\" />";
     }
     Response.Write(param);
     Response.Write(initparams);
 %>

原文地址:https://www.cnblogs.com/chriskwok/p/2192995.html