I need to download a zip file using ajax and ashx. Currently I am using the code https://stackoverflow.com/a/23797348 but the downloaded zip file is invalid.
The ashx code i am using is :
MemoryStream exportPrjtResponseMemStream = SomeClass.ReturnResponse(ID);
Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=\"" + fileName + ".zip\"");
Response.CacheControl = "Private";
Response.AppendHeader("Content-Length", exportPrjtResponseMemStream.Length.ToString());
exportPrjtResponseMemStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
Please suggest.