开发者

Asynchronous generation of PDF - error handling

开发者 https://www.devze.com 2022-12-13 10:18 出处:网络
We have some开发者_如何学C code that uses a third party component to generate a PDF from a URL that we pass it (the URL being a page within our application).In the code, we instantiate the PDF generat

We have some开发者_如何学C code that uses a third party component to generate a PDF from a URL that we pass it (the URL being a page within our application). In the code, we instantiate the PDF generator and it creates the PDF in an asynchronous fashion.

The problem I have is that if the URL that we pass it has a problem, there is no indication of this from the PDF generator, we just get a PDF created that contains a 404 error page, or our custom error page.

I need some way, within my controller, to first call this URL (which is another view) and check that it does not error out, prior to calling the PDF generation. Can anybody point me in the direction of how I might go about doing this?


You can to a HttpRequest to the URL first, then check the HttpWebResponse.StatusCode If you get a 404 or a 500 (etc) then you have a problem.


Do an Http Request first against the URL. I use WatIn for all my URL interactions, which I find sufficiently hides the details allowing me to validate a page prior to use. However for this you really just need HttpRequest

0

精彩评论

暂无评论...
验证码 换一张
取 消