Silverlight 5-使用反缓存技巧时,OOB安装/更新中断 [英] Silverlight 5 - OOB install/update broken when using anti-cache trick

查看:172
本文介绍了Silverlight 5-使用反缓存技巧时,OOB安装/更新中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Silverlight< object>上使用了时间戳记技巧. (请参见GetLastWriteTime()使用

I was using the timestamp trick on the Silverlight <object> (see GetLastWriteTime() using answers in How do you force Firefox to not cache or re-download a Silverlight XAP file?) successfully with Silverlight 4.

使用Silverlight 5运行时 * ,OOB安装/自动更新功能现在似乎已损坏.我有两个问题:

Using a Silverlight 5 runtime*, the OOB install/auto-update feature now seems broken. I have two issues:

  • 在浏览器中启动时,当前安装状态始终为未安装"(在代码中:Application.Current.InstallState == System.Windows.InstallState.NotInstalled始终为true)
  • 以OOB模式启动时,总​​是说有新版本可用(在代码中:CheckAndDownloadUpdateAsync()总是返回e.Error == nulle.UpdateAvailable == true).
  • when launching in browser, the current install state is always 'not installed' (in code: Application.Current.InstallState == System.Windows.InstallState.NotInstalled is always true)
  • when launching in OOB mode, it's always saying that a new version is available (in code: CheckAndDownloadUpdateAsync() always returns with e.Error == null and e.UpdateAvailable == true).

还有其他人遇到过这种情况吗,更好的是,有一种解决方法?

Has anyone else encountered this, and better yet, has a workaround?

* 精度::目前,我的应用是使用Silverlight 5工具构建的,但它的目标是Silverlight 4,并且在Silverlight 4 Developer Runtime上运行良好.该问题至少在使用Silverlight 5 Developer Runtime的开发机上发生.

* Precision: currently my app is built using the Silverlight 5 Tools, but is targeting Silverlight 4, and works fine on a Silverlight 4 Developer Runtime. The problem occurs on (at least) my dev machine using the Silverlight 5 Developer Runtime.

更新:我已经与Fiddler一起检查了我的开发箱上发生了什么.调用更新过程时,我看到:

Update: I've checked with Fiddler what happens on my dev box. When the update process is invoked, I see:

GET /ClientBin/Client.xap?timestamp=23%2f01%2f2012+17%3a42%3a14 HTTP/1.1
If-Modified-Since: Tue, 24 Jan 2012 09:10:07 GMT

对我来说很好,除了服务器(服务器:ASP.NET开发服务器/10.0.0.0,X-AspNet版本:4.0.30319)返回具有以下缓存头的新版本:

That's fine for me, except that the server (Server: ASP.NET Development Server/10.0.0.0, X-AspNet-Version: 4.0.30319) returns a new version, with the following cache headers:

HTTP/1.1 200 OK
Cache-Control: private
Date: Tue, 24 Jan 2012 09:11:28 GMT

每次我运行该应用程序时,检查请求都具有正确的日期(服务器先前返回的日期),并且每次服务器都说它具有一个带有当前日期的新版本.我将尝试调整服务器配置.

Each time I run the app, the check request has the right date (the one previously returned by the server), and each time, the server says it has a new version, with the current date. I will try to tweak the server config.

Update2::我的Web.config文件中有一个缓存控制指令,但是删除它只能解决一半的问题.现在,in浏览器中的应用程序检测到OOB安装已可以,但是更新周期继续,并且具有相同的Fiddler跟踪.

Update2: I had a cache control directive in my Web.config file, but removing it only solved half the problem. Now the in browser app detects that the OOB install is ok, but the update cycle continues, with the same Fiddler trace.

Update3 :该问题肯定与调试Web服务器有关.使用相同的Web.config部署到正确的IIS的相同应用程序不会出现此问题.但这仍然很烦人,因为它大大减慢了我的OOB调试过程.

Update3: The problem is definitely related to the debug web server. The same application deployed to a proper IIS with the same Web.config doesn't have this issue. But this is still annoying, as it considerably slows down my OOB debug process.

Update4:实际上,即使在我的主要IIS部署中,该问题仍然存在,并且在其他服务器上也已发生(并使用PHP生成时间戳而不是ASP.NET).因此,我们将不胜感激.

Update4: In fact, the problem is still present even on my main IIS deployment, and has happened on other servers too (and using PHP to generate the timestamp instead of ASP.NET). So any help is appreciated.

Update5:根据要求,这是我的代码,非常简单:

Update5: As requested, here is my code, fairly straightforward:

private void CheckAndDownloadUpdateCompleted(object sender, System.Windows.CheckAndDownloadUpdateCompletedEventArgs e)
{
    if (e.Error != null)
    {
        if (e.Error is PlatformNotSupportedException)
        {
            UpdateType = UpdateTypes.PlatformUpdate;
            //(...)
            return;
        }
        else if (e.Error is SecurityException)
        {
            UpdateType = UpdateTypes.ElevationRequired;
            //(...)
            return;
        }
        else
        {
            // Error handling code
            //(...)
        }
    }
    else if (e.UpdateAvailable)
    {
        UpdateType = UpdateTypes.Available;
        //(...)
        return;
    }

    UpdateType = UpdateTypes.NoUpdate;

    //(...)
}

UpdateType是一个枚举类型属性,可让我在其他位置选择正确的本地化字符串.

UpdateType is an enum type property that allow me to pick the right localized string somewhere else.

Update6 :各个//(...)部分正在(间接地)更改应用程序的视图,而UpdateType则没有.

Update6: The various //(...) parts are (indirectly) changing the view of the application, UpdateType is not.

推荐答案

从Visual Studio中作为OOB运行时,我遇到相同的问题

I have the same issue when run as OOB from Visual Studio

关于从IIS远程运行,我注意到我必须编辑添加到web.config中的缓存策略-保持该策略始终显示更新/下载进度徽标(但是下载速度比有新版本时快) ,也许只能进行部分下载,但是很讨厌每次都能看到下载进度)

Regarding running from IIS remotely, I noticed that I had to edit the caching policy I had added to web.config - keeping that would always show the update/download progress logo (but would download faster than when a new version was available, only partial download maybe, but annoying to see the download progress even for a while every time)

我必须删除(注释掉)试图缓存.xap直到更改的部分

I had to remove (comment out) the part that was trying to cache .xap till changed

<caching>
  <profiles>
    <add extension=".xap" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
  </profiles>
</caching>

这篇关于Silverlight 5-使用反缓存技巧时,OOB安装/更新中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆