我的下载内容只是从本地文件系统提供静态 zip 文件,该文件适用于 Chrome 和 Firefox,但不适用于 IE8。
该网站正在使用 SSL 在本地主机上运行,但我在 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));
}
最佳答案
这就是最终对我有用的方法。就我而言,OnActionExecuted 上有一个全局 ActionFilter 将缓存控制设置为“无缓存”。
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";
}
}
关于asp.net-mvc - ASP.NET MVC 3 文件下载 : Not Working in IE8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846054/