开发者

How to send status information from a Web service while is being executed?

I'm new to web development so I'm not sure what's the best option for the problem that I'm having.

Basically I have a web application that calls a web service for processing some data. This process may take a long time 开发者_C百科(hours) and I would to know if there is an easy way to send some status information to the client from time to time.

Right now, the client makes the request from the browser and it just waits there until it finishes.

How can I send some information from the web service? I would like to send a percentage and some additional text specifying what is being done.

Thanks


WCF services can be marked as [OneWay] so that they don't return a response. or, you could have the service kick off the process in an async manner and then just return to the client that the process has/or hasn't kicked off.

Then, the client can poll another method as the other user has suggested.

If you process takes hours you definitely can't use a sync service because you'll hit your execution timeout or rather the connection timeout for the client.


Maybe you can poll another method for status?


If I were you, I would make the original request asynchronous, as in instead of waiting for the response, it just "starts" the task and returns immediately. Then I would have a separate method on your web service that the app can poll periodically to get the status of the job. once it completes, it can display the data like the original request was doing.

if you want to do it synchronously, you can turn off Response.Buffer and write directly to the response.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜