2012-02-01 164 views
0

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

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()); 
    } 
} 

回答

0

此基础上我的测试,这是由于本地主机。 Web浏览器无法从本地主机下载。当我对生产进行部署时(Web中的真实Web服务器),它的工作完美无瑕。

相关问题