我正在使用 winnovative PDF 转换器,它在我的测试项目中正常工作。但是当我在我的原始项目中添加相同的代码时,
表明它抛出了以下异常。
我检查了
HttpResponse httpResponse = HttpContext.Current.Response;
它显示的值如上述内容。
我该如何解决这个问题。即使在 IIS 服务器中托管后,我也尝试过。
编辑:
byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(htmlWithSvgUrl);
HttpResponse httpResponse = HttpContext.Current.Response;
// add the Content-Type and Content-Disposition HTTP headers
httpResponse.AddHeader("Content-Type", "application/pdf");
httpResponse.AddHeader("Content-Disposition", String.Format("attachment; filename=SvgToPdf.pdf; size={0}", pdfBytes.Length.ToString()));
// write the PDF document bytes as attachment to HTTP response
httpResponse.BinaryWrite(pdfBytes);
// Note: it is important to end the response, otherwise the ASP.NET
// web page will render its content to PDF document stream
//httpResponse.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();