【问题标题】:Invalid manifest mime type when served via ashx handler通过 ashx 处理程序提供的清单 mime 类型无效
【发布时间】:2012-02-01 03:44:40
【问题描述】:

我正在处理程序中动态生成我的缓存清单,将内容类型设置为“text/cache-manifest”。 但是,当我在 Chrome 中加载我的缓存页面时,我在 Chrome 的控制台中收到以下错误(注意括号中的空字符串),并且文件永远不会更新:

Application Cache Error event: Invalid manifest mime type () http://localhost:4010/WebClient/CacheManifest.ashx

这在近一年前运行良好,但突然开始发生。

有什么想法吗?

这是 CacheManifest.ashx 的代码隐藏:

public class CacheManifest : IHttpHandler
{
    public bool IsReusable
    {
        get
        {
            return true;
        }
    }

    public void ProcessRequest(HttpContext context)
    {
        HttpResponse response = context.Response;
        response.Clear();
        response.ContentType = "text/cache-manifest";

        StringBuilder output = new StringBuilder();

        output.AppendLine("CACHE MANIFEST");
        output.AppendLine();
        output.AppendLine("CACHE:");

        // here's the code that loads files from disk and adds to manifest.

        // allow online resources
        output.AppendLine("NETWORK:");
        output.AppendLine("*");

        output.AppendFormat("# hash: {0}", GetContentHash());

        response.Write(output.ToString());
    }
}

【问题讨论】:

    标签: asp.net html .net-4.0


    【解决方案1】:

    根据我的测试,这是由于 localhost。 Web 浏览器无法从 localhost 下载它。当我部署到生产环境(网络中的真实网络服务器)时,它可以完美运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-03
      相关资源
      最近更新 更多