Free Support Forum -


When saving my pdf object to the Response object, when I use this code:


The pdf loads great, but when I hit back in my browser, it goes back two pages in my history. If I leave off the Response.End(), instead of just loading the pdf, I get a dialog asking if I want to Open or Save the document. When I select Open, I get an error that says:

"The file referenced by the shortcut file ‘C:…’ can not be opened."

My preference is for the pdf to load without having to select open, and that if I hit back, I’ll go back to the page from which I generated the pdf.

Any ideas?


Dear Pete,

Thanks for your consideration.

Please look at the Aspose.Pdf demos. In the demos, you can go back to the page from which you generated the pdf if you hit back.

Is it possible that you are writing other stuff to the response before or after the pdf.Save?

When writing the PDF for display, it is important to not have any other non-PDF bytes in the response stream.

Our code uses the pdf.Save(response) and it works correctly without using a response.end.

I’m not explicitly writing anything else to the response before or after the pdf.Save. Is there a way that I might be implicitly writing more to the response that I can check out?

We had a similar problem and there are several possiblities to check.

1) Does the ASPX form contain any HTML? By default, Visual Studio includes opening and closing HTML. When I created our online display pages, I went in and removed all ot the data (including whitespace from the page.)

2) Does your ASPX page inherit from a page which adds header and footer information? (Our code broke when we changed the page to inherit from a base page to add security and the base page was adding page headers and footers. We had to change the code to allow header and footer rendering to be shut off.)