【发布时间】:2012-04-03 15:19:10
【问题描述】:
我有以下代码,部署在 https Asp 站点上,使用 MVC 4.0 构建:
public FileResult ANotSoWorkingFunction(string filePath, string fileName)
{
pathToFile = string.Format("~/{0}/{1}", pathToFile, fileName);
return File(new FileStream(pathToFile, FileMode.Open), "application/pdf", fileName);
}
这将适用于 Chrome、Firefox 和 IE9(你们中的许多人可能已经猜到了)。但它会抛出一个:
---------------------------
Windows Internet Explorer
---------------------------
Internet Explorer cannot download someFileName from a_site.com.
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
---------------------------
OK
---------------------------
在 IE6、7、8 上
非常感谢任何关于这个的想法或线索,因为我已经花了一天的时间在玩 html 标头。
编辑:
这是来自 IE7 的标题:
HTTP/1.1 200 OK
Cache-Control: private, no-cache="Set-Cookie"
Content-Type: application/pdf
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
Set-Cookie: .ASPXAUTH=; expires=Mon, 11-Oct-1999 21:00:00 GMT; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Wed, 04 Apr 2012 08:43:50 GMT
Content-Length: 233324
以下是来自 IE9 的:
HTTP/1.1 200 OK
Cache-Control: private, no-cache="Set-Cookie"
Content-Type: application/pdf
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
Set-Cookie: .ASPXAUTH=; expires=Mon, 11-Oct-1999 21:00:00 GMT; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Wed, 04 Apr 2012 08:42:14 GMT
Content-Length: 233324
谢谢,
【问题讨论】:
-
您能告诉我们您的“Cache-Control”和“Set-Cookie”响应标头吗?
-
乐子当然可以,谢谢你的邀请
-
可能和mvc 3中的问题一样stackoverflow.com/questions/6943443/…