- "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New Project" - "C#" - "ASP.NET Empty Web Application" (to avoid adding a master page).
- Provide the web site a name such as "CallingWCFServiceUsingScriptManager" or another as you wish and specify the location.
- Then right-click on Solution Explorer - "Add New Item". You will see the WCF service template then click on "Add".
- Right-click on Solution Explorer - "Add New Item" - you see the Web Form template then click on Add
- Now drag and drop one ScriptManager, two text Boxes and one button on the Default.aspx Page. Then the source code of the Default.aspx page will look as follows:
In the code above, I have Implemented one method named GetAddition that takes the two integer type parameters that are a,b and returns the sum of the two integer variables.
- OnSucess: returns the results after successfully executing the WCF services method, this parameter is optional.
- Onfailed: If the WCF service method fails to execute then it returns the error details, it accepts the error object as a parameter, this parameter is optional.
- usercontext: This is used to provide some additional information, this parameter is optional.