I'm trying to export a zip file created in my controller through ajax. I've looked through several related questions, but they're all slightly different, and I haven't been able to connect the dots. Sometimes, I get nothing returned. Other times, my ajax goes to the window location and everything breaks.
My ajax call:
$.ajax({
     url: "/Somewhere/Export",
     type: "POST",
     dataType: 'html',
     data: {
         jsonModel: JSON.stringify(modelData),
         fileType: $("#toggle-2").val()
      },
      success: function (returnValue) {
           window.location = '/Somewhere/Export/Download?file=' + returnValue;
      },
});
One attempt of my controller snip.:
[HttpPost, Authorize]
public ActionResult Export(string jsonModel, int? fileType)
{
    MemoryStream workingStream = GenerateExportFile(jsonModel, fileType);
    return File(workingStream, "application/zip", folderName + ".zip");
}
I've also tried using response stream:
[HttpPost, Authorize]
public ActionResult Export(string jsonModel, int? fileType)
{
    MemoryStream workingStream = GenerateExportFile(jsonModel, fileType);
    Response.Clear();
    Response.AddHeader("Content-Disposition", "attachment; filename=" + folderName + ".zip");
    Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Zip;
    workingStream.WriteTo(Response.OutputStream);
    Response.End();
    return RedirectToAction("Index");
}
Stuff I've looked at: Generating excel then downloading , Download excel via ajax mvc , and Downloading zip through asp mvc
 
     
    