Web server calls back to web browser client machanisms in ASP.NET
Purpose:
I want to implement a machanism by which web server can make call back to web browser client.
Problem Description:
I have a project where web browser client sends web request to web server, which takes a long time to process the request, and return the result.
Tentative Solution:
Is it possible that the web server c开发者_如何转开发an make a call back to web browser client, and send data to brower cleint.
Other possible Solution
- Web browser client polling:
Downside: polling method is only considered as last resort.
2 Server Side AJAX JavaScript (if exist)
Custom server side javascipt that can talk to .net, and call web browser client javascript.
Thanks
There are currently 2 solutions for this:
- WebSockets provide a true callback, but are not widely adopted
- Use a Comet implementation (such as WebSync)
There isn't a true "callback" mechanism when dealing with web browswers as clients. Here is a link to a similar problem and potential solution.
Async method in asp.net web service
Have a look at this article on various available methods for implementing callbacks:
http://msdn.microsoft.com/en-us/magazine/cc163537.aspx
Sorry, HTTP doesn't work that way. It's a client/server, request/response protocol. You need to revisit your requirements.
The best you can do is have the browser poll the server by making requests which just respond with an "empty" answer until the server is ready to "call back".
精彩评论