我有以下代碼,部署在HTTPS Asp位點,建立與MVC 4.0:Internet Explorer錯誤
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」響應頭嗎? – Levi 2012-04-03 21:27:08
當然可以Lezi,謝謝你在這個 – Calin 2012-04-04 08:49:34
intress可能是在mvc 3相同的問題 http://stackoverflow.com/questions/6943443/asp-mvc3-fileresult-with-accents-ie8-bugged – 2012-04-19 15:01:24