zoukankan      html  css  js  c++  java
  • 强制更新客户端Silverlight XAP 文件

    在发布小程序更新的时候访问的总是原来的程序,猜想应该是缓存的原因。在网上查找方法

    <div id="silverlightControlHost">
            <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
              <param name="source" value="ClientBin/ElecDemoSl.xap?<%=Guid.NewGuid().ToString() %>"/>
              <param name="onError" value="onSilverlightError" />
              <param name="background" value="white" />
              <param name="minRuntimeVersion" value="5.0.61118.0" />
              <param name="autoUpgrade" value="true" />
              <param name="enableGPUAcceleration" value="true" />
              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none">
                   <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" style="border-style:none"/>
              </a>
            </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;0px;border:0px"></iframe></div>

    在<param name="source" value="ClientBin/ElecDemoSl.xap?<%=Guid.NewGuid().ToString() %>"/>这行中添加绿色的代码就可以了。

    以下方法通过网上查找

    另一个解决方案,我更喜欢甚至包括检查XAP创建日期,并附加参数name =“Source”来源

    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
    
    <%
        string strSourceFile = @"ClientBin/SilverlightApplication2.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);
    %>
    <param name="onError" value="onSilverlightError" />

    参考文章

    http://www.codeproject.com/Articles/143414/Prevent-your-Silverlight-XAP-File-from-Caching-in

    http://kevinfan.blog.51cto.com/1037293/933181/

  • 相关阅读:
    [LC] 71. Simplify Path
    [LC] 225. Implement Stack using Queues
    [Coding Made Simple / LeetCode 1235] Maximum Profit in Job Scheduling
    [Coding Made Simple] Cutting Rod for max profit
    [Coding Made Simple] Longest Common Substring
    [GeeksForGeeks] Convert an array to reduced form
    [GeeksForGeeks] Find if there is a pair with a given sum in a sorted and rotated array.
    [Coding Made Simple] Optimal Binary Search Tree
    [GeeksForGeeks] Write a program to delete a tree
    [GeeksForGeeks] Check if two trees are Isomorphic
  • 原文地址:https://www.cnblogs.com/ZJ199012/p/3552416.html
Copyright © 2011-2022 走看看