Posted on: 7/29/2015 7:43:45 PM | Views : 843

I am prototyping streaming a pdf file from a Web API, and after the download, I double click on the file and it says "Can't open this file. There's a problem with the file format". From what I can see and have learned, I am not too sure what the problem is. So, what I have done is to copy both methods - the first one is the Web API method - server side and the last method is the calling method - client side: SERVER SIDE METHOD HttpResponseMessage result = null; result = Request.CreateResponse(HttpStatusCode.OK); result.Content = new StreamContent(new FileStream(pdfDoc, FileMode.Open, FileAccess.Read)); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = "ExamplePDF.pdf"; return re ...

Go to the complete details ...