Question

Handling a pdf response from an ashx handler call. I have a generic ashx handler in C# 4.0 that creates a pdf for me. I call this handler from javascript in a browser by building a url to send to the handler. So my final call to obtain the pdf is this:

 window.open(_url, '_self', false);

the problem i have with this is that i cannot but a spinning gif up to tell the user that the pdf is cooking and will be ready soon. I just don't have an access point where i can say 'the report is working hold on a moment'. Because when that call comes back it attempts to open the pdf - which, in my browser, brings up the box asking you to open or save the pdf.

Is there another way I can make this call so that when the pdf doc comes back i can execute some code to make the spinny go away?

Was it helpful?

Solution

Are you opening up the PDF in the same window or in a new window? if a new window, the quick&easy would be to have your link go to a "loading, please wait..." page, which then does a redirect to the ashx page. the "loading please wait" will stay on the screen until the other page is ready to be rendered. Or you could have the ashx file first render a "please wait message", and then wipe the response and render the PDF once it's done (trickier). If on the same page, you could use some simple jquery/javascript that would call a function that popups a new layer with a "loading please wait.." that the user would see until the page is redirected to the rendered PDF.

hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top