【问题标题】:HTML 5 Application Cache IE10/11 AppCache Fatal Error when Chrome and Android are workingChrome 和 Android 工作时的 HTML 5 应用程序缓存 IE10/11 AppCache 致命错误
【发布时间】:2014-07-22 18:38:09
【问题描述】:

我创建了一个简单的测试 ASP.NET MVC 应用程序来尝试使用应用程序缓存。 Chrome 似乎工作正常,但是在 IE 10/11 中,它在尝试下载缓存时向我们提供以下消息。任何想法或示例在哪里起作用?

我尝试了很多方法,包括下载一个较小的文件。我看到有一个限制会导致类似的错误。

清单

CACHE MANIFEST
#VERSION 9

CACHE:
/Content/site.css

NETWORK:
*

FALLBACK:

索引视图

@{
    Layout = null;
}

<!DOCTYPE html>

<html manifest="home/manifest">
<head>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
    <meta http-equiv="EXPIRES" content="0" />
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <title>Offline Test</title>
    <link rel="Stylesheet" href="/Content/site.css"
          type="text/css" />
    <script src="/Scripts/jquery-1.10.2.min.js"
            type="text/javascript"></script>
    <script>
        $(function () {

        });
    </script>
</head>
<body>

</body>
</html>

MVC 控制器

[OutputCache(Duration = 0, NoStore = true)]
public class HomeController : Controller

MVC 动作

    public ContentResult Manifest()
    {

        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        return new ContentResult
        {
            ContentType = "text/cache-manifest",
            Content = RenderPartialViewToString("Manifest"),
             ContentEncoding = System.Text.Encoding.UTF8

        };

        // Doesn't work.  Content type is still html
        //Response.ContentType = "text/cache-manifest";
        //Response.ContentEncoding = System.Text.Encoding.UTF8;
        //Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        //return PartialView();
    }

我尝试在 Application_EndRequest 处理程序中添加 SetNoStore() 调用,但没有任何区别。

    public override void Init()
    {
        base.Init();

        EndRequest += Application_EndRequest;
    }

    private void Application_EndRequest(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Cache.SetNoStore();
    }

谢谢!

【问题讨论】:

  • 在我看来,服务器没有向根文件请求返回任何内容,即 404。 appCache 请求未记录在网络选项卡 AFAIK 中。打开提琴手,看看是否提出了请求以及发生了什么。如果这没有帮助,那么在您的 MVC 控制器中设置一个断点以查看是否请求了内容以及会发生什么。我的猜测是 Chrome 可能也失败了,但不会让你知道。

标签: asp.net-mvc internet-explorer google-chrome caching html5-appcache


【解决方案1】:

删除Cache-Control-Header 中的no-store,它会破坏IE10/IE11 中的appCache(参见https://stackoverflow.com/a/21272714/1039180)。

【讨论】:

  • 这修复了它。谢谢!
  • 你能分享你的答案吗,我尝试离线模式并有同样的错误?
猜你喜欢
  • 2013-05-27
  • 2014-04-06
  • 1970-01-01
  • 2020-03-23
  • 1970-01-01
  • 2021-09-05
  • 1970-01-01
  • 2018-09-11
  • 1970-01-01
相关资源
最近更新 更多