views:

31

answers:

3

Reporting system has list of available reports on a web page. When user clicks on a report new browser window opens, server starts to prepare report (winword document) and then sends it back after 2-10 seconds.

Code in the handler looks like the following:

 context.Response.AddHeader("Content-Disposition", 
   "attachment;filename=report.doc");
 context.Response.BinaryWrite(reportDocument);

I want to show "please wait" in this new window. Is it possible to prepare html content immediately ("please wait") send it back and then continue with time-consuming report preparation not closing connection?

What do you suggest if it's not possible to return multiple content types per one http request?

Thank you in advance!

+2  A: 

One HttpResponse can only have sigle MIME type. You can pop-up another window which in turn can call the server which will respond with winword report document.

this. __curious_geek
It look like we can (theoretically): http://bytes.com/topic/asp-net/answers/489209-transmit-file-html-response
Andrew Florko
+1  A: 

You could create an html Loading page with a redirect to the binary content.

The redirect could be done using meta redirect

<meta http-equiv="refresh" content="0;url=http://example.com/" />

More info at wikipedia

Francisco Campos
Cool! But there said that it's deprecated technique. Is it reliable?
Andrew Florko
i've been using that way and javascript like:<html><head><script type="text/javascript">self.location='http://xpto.com';</script></head><body></body></html>
Francisco Campos
It's a pity but meta tag as well as javascript approach pops up a new browser window when download report file (would you like to open in microsoft word? yes/no). Whatever I choose old "please wait" window stays on the screen and I found no ability to determine the moment when document is downloaded to close it
Andrew Florko
If you add Response.AddHeader "Content-disposition","attachment;filename=myfile.doc" it will appear a "Save? yes/no". If you add Response.AddHeader "Content-disposition","inline;filename=myfile.doc" it will display the document in the browser (if you have office installed in this case). Do you think this can help you? (this server-side code that I use in asp vbscript)
Francisco Campos
open/save dialog still present. But yes, now it opens inside browser.
Andrew Florko
got your problem solved?
Francisco Campos
not yet, really. Decided to abandon this feature for a while
Andrew Florko
+1  A: 

You cannot send 2 types of content per response. What you can do is render a "Please wait" page which contains a request (like an iframe) to the binary content.

SirDemon
It looks like we can: http://bytes.com/topic/asp-net/answers/489209-transmit-file-html-response
Andrew Florko
@Andrew Florko , the link looks like a possibility for Http in general, not sure if it'll work on asp.net, but it looks interesting. If you manage to find a way, I'd love to see an example.
SirDemon
The problem with iframes -- I can't determine the time report document is loaded into iframe. IFrames pop up a new window for winword and previous one is not closed.
Andrew Florko