Asynchronous ASP.NET Server Output
Question: I have a web interface where a user 开发者_JAVA百科can upload an XML file, which then gets imported into a SQL database.
Import works fine, interface works fine, logfile works fine. The problem: The user doesn't get any progress report until the entire file has been processed...
Is there any way the server can output logfile messages to the user page while processing? I mean AJAX doesn't work for server side calls to the client, only vice-versa, or is there a workaround ?
Have you looked at thee articles? might be of some help
Reverse Ajax Using Hidden IFrame and Using Server Push (aka Reverse AJAX)
Edit: We have a similar question too : asp.net http server push to client
If you set response.Buffer to false, anything written to the response will be sent to the client immediately rather than sending everything waiting for the response to end.
This works best with text output of course - I use this approach for displaying server console output in the browser. To integrate it with an html page, you would use jquery to post the file to a page that returns only text, and set up a data received handler to update the ui as messages come through on the text file.
精彩评论