0

I'm using winnovative PDF converter and its working properly on my test project. but when i add same code to my original project,

shows that it throws following exceptions. exception]![enter image description here

i checked value of

 HttpResponse httpResponse = HttpContext.Current.Response;

and it shows values as above content.

how can I solve this. I tried this even after hosting in IIS server as well.

Edit:

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();
DevT
  • 4,843
  • 16
  • 59
  • 92
  • Are you using IIS 7.5 or higher and is your application pool set to *Integrated pipeline mode*? – user247702 Nov 08 '13 at 09:32
  • @Stijn even i run this in iis 7.5 its not working. in this case it's not throw any exception. only PDF is not generated. so because of that i look into `Response` and it shows above exceptions – DevT Nov 08 '13 at 10:15
  • Can you check what the output of `System.Web.HttpRuntime.UsingIntegratedPipeline` and `System.Web.HttpRuntime.IISVersion` is? – user247702 Nov 08 '13 at 10:37

1 Answers1

0

If your IIS version is 7.5 or higher, then the exception message which we should focus may be "this operation requires iis integrated pipeline mode"

I found this answer from this link http://forums.asp.net/t/1253457.aspx

As the error message indicated, it requires IIS integrated pipeline mode. Please select the application pool in IIS Manager, Click "Basic Settings..." and make sure "Integrated" mode is selected for "Managed pipeline mode" in the dialog.

Could you please check that?

Alice
  • 1,255
  • 1
  • 9
  • 7
  • even i run this in iis 7.5 its not working. in this case it's not throw any exception. only PDF is not generated. so because of that i look into `Response` and it shows above exceptions – DevT Nov 08 '13 at 10:15
  • Could you please try this code instead? **Response.AddHeader("content-disposition", "attachment; filename=SvgToPdf.pdf"); Response.BinaryWrite(pdfBytes);** – Alice Nov 08 '13 at 11:18
  • even nothing change.. still pdf is not generated. – DevT Nov 08 '13 at 11:54
  • Have you had put breakpoint and debug your code? I would know which line was thrown the exception. – Alice Nov 08 '13 at 12:20
  • its not thrown any exception. but when i put break point in `HttpResponse httpResponse = HttpContext.Current.Response;` line it shows above pic info – DevT Nov 08 '13 at 14:48
  • Have you used **UpdatePanel** Control with the button (any control for user to click and then do the exporting PDF)? If so you have to add a post back trigger for that UpdatePanel – Alice Nov 08 '13 at 15:14