Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从safari ASP.NET下载时加载资源失败错误_Javascript_C#_Asp.net_Safari - Fatal编程技术网

Javascript 从safari ASP.NET下载时加载资源失败错误

Javascript 从safari ASP.NET下载时加载资源失败错误,javascript,c#,asp.net,safari,Javascript,C#,Asp.net,Safari,我使用的是ASP.NETMVC5,从Safari下载文件时遇到错误,它在FireFox/Chrome上正常工作 在我的网站上,我试图下载xls文件,这显示了错误(来自Safari) [错误]加载资源失败:帧加载中断 这是我的代码片段 var memStream = new MemoryStream(encoding.GetBytes(model.ExportGenericHtml(true))); HttpResponseMessage fullResponse = &g

我使用的是ASP.NETMVC5,从Safari下载文件时遇到错误,它在FireFox/Chrome上正常工作

在我的网站上,我试图下载xls文件,这显示了错误(来自Safari)

[错误]加载资源失败:帧加载中断

这是我的代码片段

var memStream = new  MemoryStream(encoding.GetBytes(model.ExportGenericHtml(true)));
           HttpResponseMessage fullResponse = >Request.CreateResponse(HttpStatusCode.OK);
           fullResponse.Content = new StreamContent(memStream);
           fullResponse.Content.Headers.ContentType = _XlmediaType;
        // Response.AddHeader("Content-Length", data.Length.ToString());
           fullResponse.Content.Headers.Add("Content-Length",  memStream.Length.ToString());
           string fileName = "transactions.xls";
           fullResponse.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("fileName") { FileName = fileName };
           fullResponse.Content.Headers.Add("x-filename", fileName);
           return fullResponse;
有没有办法解决此错误?

检查以下参数:

显然,上述答案中的内容类型与您的需要不匹配,但应验证其他参数。

检查这些参数:


显然,上述答案中的内容类型与您的需要不匹配,但其他参数应进行验证。

是否使用锚定标记?是否使用锚定标记?
header("Pragma: public"); // required
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: private",false); // required for certain browsers 
header("Content-type: application/x-unknown"); // I always use this
header("Content-Disposition: attachment; filename='theFilename.ext'");
header("Content-Transfer-Encoding: binary");
header("Content-Length: 177998"); // you might want to set this