I'm trying to create and showing a pdf from my webpage by clicking a link. But when the system has to show it goes something wrong.
When I use this command
return new FileStreamResult(fileStream, "application/pdf");
It shows a empty pdf file:
///C:/Users/Me/Downloads/C--Apps-MyWebSolution-MyWeb-Documenten-MyList_198721.pdf
It is saved as: C:AppsMyWebSolutionMyWebDocumentenMyList_198721%20.pdf
And when I use this command:
return File(fileStream, "application/pdf", fullFileName);
then I get an error message:
ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
What am I doing wrong?
public FileStreamResult PDFGenerator(string html, string fileName)
{
string fullFileName = Server.MapPath("~/Documenten/" + fileName + ".pdf");
Stream fileStream = CreatePDF(html, fullFileName);
HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" + fullFileName);
//return new FileStreamResult(fileStream, "application/pdf");
return File(fileStream, "application/pdf", fullFileName);
}
If I had to post more. I'll do it. But I don't think it is needed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…