- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法使用 Web API get 调用从服务器成功下载文件。下载似乎开始了,但随后 Chrome 抛出:
“资源被解释为文档,但使用 MIME 类型应用程序/zip 传输”
Firefox 没有说,但下载仍然失败。
我在以下设置中做错了什么?:
[HttpGet, Route("api/extractor/downloadresults")]
public HttpResponseMessage DownloadResultFiles()
{
int contentLength = 0;
this.ResultFiles.ForEach(f => contentLength = contentLength + f.FileSize);
var streamContent = new PushStreamContent((outputStream, httpContext, transportContent) =>
{
...zip files...
});
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
streamContent.Headers.ContentLength = contentLength;
streamContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "result.zip"
};
var response = Request.CreateResponse();
response.StatusCode = HttpStatusCode.OK;
response.Content = streamContent;
}
window.location.href = "api/extractor/downloadresults";
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:ASP.NET_SessionId=ibwezezeutmu2gpajfnpf41p
Host:localhost:47384
Referer:http://localhost:47384/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Cache-Control:no-cache
Content-Disposition:attachment; filename=result.zip
Content-Length:436102
Content-Type:application/zip
Date:Mon, 16 Dec 2013 22:36:31 GMT
Expires:-1
Persistent-Auth:true
Pragma:no-cache
Server:Microsoft-IIS/8.0
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcbmV3VG9vbGJveFxUb29sYm94XFRvb2xib3guV2ViXGFwaVx0ZXJtZXh0cmFjdG9yXGRvd25sb2FkcmVzdWx0ZmlsZXM=?=
最佳答案
您是否尝试过更改请求 header ,例如接受 header ?
另外,here您可以找到类似的问题,那里建议的一些解决方案可能对您有所帮助。
关于asp.net-mvc - 资源被解释为文档,但使用 MIME 类型应用程序/zip : 传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20622532/
如果上传的文件没有扩展名,是否必须指定 MIME 类型?换句话说,是否有默认的通用 MIME 类型? 最佳答案 对于未知类型,您可以使用application/octet-stream。 RFC 20
MIME 类型的官方 URN 是否存在? Mozilla Firefox 和其他应用程序使用诸如“urn:mimetype:text/plain”或“urn:mimetype:handler:text
我们有一个由 xyz 网站管理员部署在生产环境中的网站。以下是在两个不同实例中发生错误时 Web 控制台的两个屏幕截图。 我们时断时续地而不是始终如一地面对这个问题。此外,这种情况发生在少数用户而不是
此错误仅在 chrome 中显示。我正在搜索这个问题,但还没有找到 令人满意的解决方案。我附上了该错误的屏幕截图。请为此提出一些想法。 Error image 最佳答案 样式表的 MIME 类型应该是
当我使用 MAMP 托管我的 Drupal 站点时,出现了上述错误。我所有的 HTML 加载,但我的 CSS 没有加载。 拒绝应用来自“http://mysite/sites/default/file
错误信息: jquery.dataTables.min.js:23 未捕获类型错误:无法读取未定义的属性“长度” 在 Ha (jquery.dataTables.min.js:23) 在 HTMLTa
Raw images由相机、扫描仪等生成,通常比 JPEG 图像具有更大的后处理灵活性。 如果我从我的 Web 服务器提供这种文件,我应该使用哪种媒体类型(又名 MIME 类型)? 我对最近的佳能相机
我已经查看了大约 100 个站点,但没有找到任何内容。有些只是 mime 类型值的列表,有些只是对 RFC 的引用,或者或多或少是直接引用它们。 RFC 是难以理解的,每一个都只揭示了大象的一小部分。
我想用 image/*数据 URI 中的 MIME 类型,例如data:image/*;base64,R0lGODlhE...在 元素。 它是否完全符合标准的 MIME 类型? 它会在某些浏览器中引起
我有一个 PHP 脚本,用于下载不同类型的文件(PDF、JPEG、RAR 等)。效果很好,但是我注意到 MIME 类型存在问题。 是否有我可以安全地用于“通用目的”的通用 MIME 类型?我正在考虑所
我的程序使用自己的二进制文件类型,因此我假设我不能使用 MIME 类型文本/纯文本,因为它不是 7 位 ASCII 文件。 我应该将其命名为“application/myappname”吗? 最佳答案
我正在调试一个 MIME 解析器,它无法解析来自一个电子邮件服务的 header 。电子邮件服务包含一个 header ,该 header 由完全位于下一行的字段主体组成,如下所示: Message-
我有一个 Vue.js 项目,当我检查控制台时发现以下问题: Refused to apply style from 'http://localhost:8080/dist/cropper.min.c
friend 们,我花了一整天的时间寻找这个问题的解决方案,但我一直无法修复它。当我为生产构建它时,在开发模式下(没有缩小和其他东西)它在本地主机上运行良好,但是当我在 dist 文件夹中获取我的文件
Swagger 默认支持 application/json 作为 Content 类型。如果我想添加其他内容类型,则需要在 swagger JSON 文件中更新“生产”或“消费”字段。客户可以发送任何
我的网络服务生成并返回一个 .tex 文件。我想在 http-header 中提供正确的 mimetype。 除了here我没找到这么多,我在其中找到 application/x-tex。这是要坚持的
我需要区分不同类型的 HTML 模板,例如来自 Handlebars 模板的 FreeMarker。由于模板在数据库中(所以它们不是文件,即没有文件名或扩展名)我想使用 MIME 类型来识别它们。 对
我想知道 iWork 页面的 mime 类型是什么?以及 iWork 套件中其余软件的 mime 类型是什么?我在网上环顾四周,没有看到任何地方。 最佳答案 我最近需要这个来工作,结果只是上传了一些文
我正在构建一个 mime 类型的猜测器,我正在使用 mimetype命令来检查我的结果。对于日志文件,它返回 text/x-log .我在这些列表中没有看到这种 mime 类型: http://svn
有谁知道 Markdown 是否存在 MIME 类型?我猜是 text/plain,但是有更具体的吗? 最佳答案 tl;dr:text/markdown 自 2016 年 3 月起 2016 年 3
我是一名优秀的程序员,十分优秀!