c# - How to return a PDF in an action result in MVC -


i have little problem getting head around problem. have ajax call should render iframe loads pdf. pdf generated using apache fop hosted in environment. have far is:

in controller action (where src element of iframe points), code snippet is:

var targetstream = new memorystream();     using (var response = foprequest.getresponse()) // response fop                 {                     using (var stream = response.getresponsestream())                     {                         stream.copyto(targetstream);                      }                 }  return new filestreamresult(targetstream, "application/pdf"); 

however, not work expected. stream populated expected, pdf not render in iframe. http response code of 200 (ok).

i'd grateful of help.

you use mvc filecontentresult return actionresult example:

return file(filearray, contenttype, filename) 

another stack answer


Comments