The following example uses WCF to create a service port that can be accessed by the ASP.net page through a jquery Ajax approach, and we will use AJAX technology on the client to communicate with the WCF service. Here we only use jquery to connect to the Web service instead of using the ASP.net Ajax Library, as for why we don't use AJAX libraries, because we've already used jquery in our projects, and it's already able to handle all the Ajax requests and all the functionality, and If we were to use the ASP.net Ajax library, we would also have to include more than 80Kb of data (more in debug mode), but that's not to say that ASP.net Ajax libraries are not practical, in fact, if you use the same class library, we can write a lot of extra code less, But this example is to illustrate how we invoke Web services without a good client agent.
WCF Services:
We first create a website and then add a ajax-enabled WCF service to create a WCF services. (Make sure you're using the correct. Net Framework version, I'm using 3.5)
After we have added the service, it automatically enters the post code file for the service, and goes ahead and browse around the file for a second.
The first thing we have to do is to find "aspnetcompatibilityrequirements" and set its value to "allowed":
[Aspnetcompatibilityrequirements (Requirementsmode = aspnetcompatibilityrequirementsmode.allowed)]
This property is set to run our service in the ASP.net compatibility mode, and if we do not set the value to "allowed", then we cannot access the service through ASP.net, which is when you add "ajax-enabled WCF Service "is generated automatically. Please refer to MSDN for more details.