AppCache - 清单错误(4)

时间:2015-02-27 07:33:28

标签: google-chrome html5-appcache

我很难调试为什么appcache对我不起作用。在最新的Chrome上,我遇到了以下错误:

 Creating Application Cache with manifest http://localhost/BEST/Home/Manifest
(index):1 Application Cache Checking event
(index):1 Application Cache Error event: Manifest fetch failed (4) http://localhost/BEST/Home/Manifest

更具体(来自onerror方法):

     ApplicationCacheErrorEvent {
    message: "Manifest fetch failed (4) http://localhost/BEST/Home/Manifest", 
    status: 4294967295, 
url: "http://localhost/BEST/Home/Manifest", 
reason: "manifest", 
clipboardData: undefined…}
bubbles: false
cancelBubble: false
cancelable: false
clipboardData: undefined
currentTarget: ApplicationCache
defaultPrevented: false
eventPhase: 0
message: "Manifest fetch failed (4) http://localhost/BEST/Home/Manifest"
path: NodeList[0]
reason: "manifest"
returnValue: true
srcElement: ApplicationCache
oncached: null
onchecking: null
ondownloading: null
onerror: function (a,b,c)
onnoupdate: null
onobsolete: null
onprogress: null
onupdateready: null
status: 0
__proto__: ApplicationCache
status: 4294967295
target: ApplicationCache
oncached: null
onchecking: null
ondownloading: null
onerror: function (a,b,c)
onnoupdate: null
onobsolete: null
onprogress: null
onupdateready: nullstatus: 0
__proto__: ApplicationCache
timeStamp: 1425021666357
type: "error"
url: "http://localhost/BEST/Home/Manifest"
__proto__: ApplicationCacheErrorEvent

我的清单非常简单:

CACHE MANIFEST

CACHE:
Content/DataTables-1.10.3/language/polish.json

NETWORK:
*

即使manifesto没有帮助

enter image description here

清单文件由ASP.NET MVC操作提供,但我认为并不重要。 以防代码:

public ActionResult Manifest()
        {
            //Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            var text = System.IO.File.ReadAllText(HttpContext.Server.MapPath("../a.appcache"));

            return new ContentResult()
                 {
                     ContentType = "text/cache-manifest",
                     Content = text,
                     ContentEncoding = System.Text.Encoding.UTF8
                 };
        }

[编辑]

在胜利的Safari上我得到了

Application Cache manifest could not be fetched, because a redirection was attempted.

也许这是一个问题? 这是我从连接到chrome的小提琴手那里得到的: enter image description here

我知道,有一个302,但这可能是问题吗? 我不知道如何将它改为200。

[EDIT2]

我在Manifest操作中手动设置状态代码并开始工作:

public ActionResult Manifest()
        {
            //Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            var text = System.IO.File.ReadAllText(HttpContext.Server.MapPath("../BEST.appcache"));

            Response.StatusCode = 200;

            return new ContentResult()
                 {
                     ContentType = "text/cache-manifest",
                     Content = text,  
                     ContentEncoding = System.Text.Encoding.UTF8
                 };
        }

但只是暂时的......经过几次测试,现在我得到了不同的错误。这个时间被设置为签名的原因,而不是显示:

  Application Cache Error event: Failed to parse manifest http://localhost/BEST/Home/Manifest
(index):252 
ApplicationCacheErrorEvent {
message: "Failed to parse manifest http://localhost/BEST/Home/Manifest", 
status: 0, 
url: "", 
reason: "signature", 
clipboardData: undefined…}
bubbles: false
cancelBubble: false
cancelable: false
clipboardData: undefined
currentTarget: ApplicationCache
defaultPrevented: false
eventPhase: 0
message: "Failed to parse manifest http://localhost/BEST/Home/Manifest"
path: NodeList[0]
reason: "signature"
returnValue: true
srcElement: ApplicationCache
status: 0
target: ApplicationCache
timeStamp: 1425025030583
type: "error"
url: ""
__proto__: ApplicationCacheErrorEvent

1 个答案:

答案 0 :(得分:0)

解决方案是将状态代码设置为200,并且无法定义无存储头。