Wow, you are asking about many different layers in one question.
Callbacks, not events
You are trying to do something specific to .NET and are not directly tied to web service programming. You cannot use events / delegates in web services. Instead, you should define what is called a "callback contract." This is another interface on which there are methods that represent the notifications you want to inform the caller and apply to your service contract as follows:
public interface MyCallbackContract { void ProgressChanged(float percentComplete); } [ServiceContract(CallbackContract = typeof(MyCallbackContract)] public interface MyServiceContract { void UploadFile(Stream stream); }
Callbacks now require two-way (duplex) communication, so if you just use basicHttpBinding now, you will need to switch to using wsDualHttpBinding or not binding to the http address at all, which will interop this service out of the water. Assuming your service is completely intranet, this should not be showstopper.
Learn a lot more about the callback programming model, which I will not go into. Instead, I will give you the amazing MSDN article by Yuval Lowy that details this issue.
How does this help me in the browser?
The second part of your question is how you can get this information from the browser, and, firstly, we must admit that there is definitely no way for it to communicate directly with the service provided. Instead, you will need to create an AJAX bridge service. Since the browser here is pure HTTP, you must upload files using POST to the REST-based WCF service. If you want to simultaneously receive status about this download, you will need to make polling requests in order to receive status.
Honestly, this is one of those places where the browser still just sucks like a platform. The browser knows how much data it sent, you should be able to report progress only on the basis of this, but it is not displayed anywhere. That's why people are turning to the Flash-based download utility because Flash really reveals this data, and so you donβt need to poll the server to make progress.
source share