Web api has this method;
public HttpResponseMessage GetReport()
{
var data = Logic.GetReportAsByteArray(...);
HttpResponseMessage response = new HttpResponseMessage();
response.Content = new ByteArrayContent(data);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = "filename.pdf";
response.StatusCode = HttpStatusCode.OK;
return response;
}
Web client consumes through this method;
...
var request = new HttpRequestMessage(...)
HttpClient client = new HttpClient();
var response = await client.SendAsync(request);
var data = await response.Content.ReadAsByteArrayAsync();
return File(data, "application/pdf", "filename.pdf");
...
When I run on local I get pdf file as output via my web client. And via Swagger I can also get file output. But when I deploy on IIS server then I get blank pdf via my web client and via Swagger I get no file at all and response body has only the next one:
{
"Version": {
"_Major": 1,
"_Minor": 1,
"_Build": -1,
"_Revision": -1
},
"Content": {
"Headers": [
{
"Key": "Content-Type",
"Value": [
"application/pdf"
]
},
{
"Key": "Content-Disposition",
"Value": [
"attachment; filename=filename.pdf"
]
}
]
},
"StatusCode": 200,
"ReasonPhrase": "OK",
"Headers": [],
"RequestMessage": null,
"IsSuccessStatusCode": true
}