【发布时间】:2012-11-12 06:11:56
【问题描述】:
我在这里遇到了一个奇怪的问题:在 ASP.NET 控制器中我这样做:
public ActionResult ExportTex()
{
Response.ContentType = "text/plain";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.HtmlEncode("overview.tex") + "\"");
return View(_model);
}
这应该让我的浏览器 (FireFox 17) 打开文件下载对话框并使用相应的文件名进行下载。然而,无论我如何在 Content-Disposition 标头中命名文件(即当通过 FireFox 下载时,文件名为 overview.tex.sdx)。
如果有人能向我解释这个附加扩展的来源,我将不胜感激。
只有 FireFox 有这种行为。 Chromium 反而像一个魅力。
//edit 根据要求,以下是 FireFox 获取的标头:
X-SourceFiles:=?UTF-8?[... doesn't matter I guess]?=
X-Powered-By:ASP.NET
X-AspNetMvc-Version:4.0
X-AspNet-Version:4.0.30319
Vary:Accept-Encoding
Set-Cookie:.ASPXROLES=; expires=Mon, 11-Oct-1999 22:00:00 GMT; path=/; HttpOnly
Server:Microsoft-IIS/8.0
Date:Sat, 24 Nov 2012 15:13:40 GMT
Content-Type:text/plain; charset=utf-8
Content-Length:7975
Content-Encoding:gzip
Content-Disposition:attachment;filename="overview.tex"
Cache-Control:private, s-maxage=0
【问题讨论】:
标签: asp.net asp.net-mvc-3 firefox razor content-disposition