2

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));
}
Abe
  • 6,386
  • 12
  • 46
  • 75
  • Have you tried `FileResult` instead of `ActionResult` (not sure if that's MVC4 only)? – Nate May 30 '13 at 21:43
  • I removed the if block and set the return type to FileResult, but I got the same error. – Abe May 30 '13 at 21:46

2 Answers2

2

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";
    }
}
Abe
  • 6,386
  • 12
  • 46
  • 75
1

The information in the following question should help you...

Struts application - unable to download file through https on IE

Community
  • 1
  • 1
davmos
  • 9,324
  • 4
  • 40
  • 43