I am working with a c# web api controller, where my code is supposed to create several word documents and zip them into a zip file. I am using Ionic.Zip to zip the file and return it to the code below as the input parameter. The code is supposed to push the zip file to the user to download, but it is loading the zip file in a window instead.
I am using the following code:
protected HttpResponseMessage ZipContentResult(ZipFile zipFile)
{
// inspired from http://stackoverflow.com/a/16171977/92756
var pushStreamContent = new PushStreamContent((stream, content, context) =>
{
zipFile.Save(stream);
stream.Close(); // After save we close the stream to signal that we are done writing.
}, "application/zip");
return new HttpResponseMessage(HttpStatusCode.OK) {Content = pushStreamContent};
}
But when I run it, the zip file loads into the window instead of prompting to save the file.
this is what I get when I run it:
PKxS�I$$filedocumentname.docx
�0�L�G@.�L�G@.�L���UP@�-JB��ew.
�\��u��$8��;0�\w�����Su�s��y��z��U�]�ת���*�3r,�L6zy4�O00>`a`�a�xj���i��i���f�a��������S��O1���F��pQ�x�R��
�W�ȟ<vJS�8ZTGCZ�Y/....
any ideas of what I am doing wrong or how to fix this?
much appreciated.