问题
I have the Download that simply serves a static zip file from the local file system that works in Chrome and Firefox, but not in IE8.
The website is running on localhost with SSL, but I am getting the following error message in IE.
Unable to download Download/ from localhost.
Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
public ActionResult Download(long batchID)
{
var batchFilePath = string.Format(BatchOrderReportsFolder + "\\Batch-{0}\\Batch-{0}.zip", batchID);
if (!System.IO.File.Exists(batchFilePath)) {
return RedirectToAction("Index", "Error");
}
return File(batchFilePath, "application/zip", Path.GetFileName(batchFilePath));
}
回答1:
Here's what ultimately worked for me. In my case, there was a global ActionFilter on OnActionExecuted that was setting cache-control to "no-cache".
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
var browserInfo = Request.Browser.Browser;
if (filterContext.Result is FileResult) {
filterContext.HttpContext.Response.CacheControl = browserInfo == "IE" ? "private" : "no-cache";
}
}
回答2:
The information in the following question should help you...
Struts application - unable to download file through https on IE
来源:https://stackoverflow.com/questions/16846054/asp-net-mvc-3-file-download-not-working-in-ie8