WCF/WF - Web page calling from WCF service - Asked By Bhavesh D on 25-May-10 01:57 AM

Hi Experts,

I want to know, how to call ASP.Net web page from WCF service in web client application.

Means, have created web page in WCF service, now I want to call it in client application. Is it possible ?

Your co-operation is highly appreciated.


regards
Bhavesh
Phivos Stylianides replied to Bhavesh D on 25-May-10 06:37 AM
Your ASP.NET page can subscribe to be notified with a WCF service when some data changes or some other event occurs. Here is an excellent tutorial using Silverlight, you should be able to use similar logic in a web forms app:
brajesh verma replied to Bhavesh D on 25-May-10 07:22 AM
Use of ICallbackEventHandler:

To use ICallbackEventHandler, we will need to inherit it on the page or in a user control. The code will for this will be:

public partial class Default2 : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler

As a result of inheriting from ICallbackEventHandler, we have to implement two functions, namely:

  • public void RaiseCallbackEvent(String eventArgument)
  • public String GetCallbackResult()

As name of the above two functions indicates, the first function gets called automatically whenever there is a CallbackEvent. After the first function the second function i.e. GetCallbackResult gets called and returns a string to the client

So how to raise a CallbackEvent? For this we will have to use javascript. There will be two javascript functions:

  1. A function which will call RaiseCallbackEvent.
  2. A function which will handle the response from the server. This function will be called automatically after GetCallbackResult() and the string returned by GetCallbackResult will appear in JavaScript as input to this function.
Bhavesh D replied to Phivos Stylianides on 26-May-10 12:18 AM
Thanks..