How to return a pdf in Web Api C # without doing dowload and open in Browser?

0

Good afternoon,

I'm using httpResponseMessage , every request it downloads. Did you want it to appear in your browser when prompted?

HttpResponseMessage responseMsg = new HttpResponseMessage(HttpStatusCode.OK);
responseMsg.Content = new ByteArrayContent(file);
responseMsg.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
responseMsg.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");

Sincerely,

    
asked by anonymous 09.08.2018 / 21:12

1 answer

0

Try changing ContentDisposition to inline instead of attachment , in FileName property add the name of your PDF file.

responseMsg.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
{
    FileName = "NomeArquivo.pdf"
};
    
09.08.2018 / 21:34