AJAX Service Without Configuration
The ConfigFreeAjaxService sample demonstrates how to use Windows Communication Foundation (WCF) to create a basic ASP.NET Asynchronous JavaScript and XML (AJAX) service (a service that you can access by using JavaScript code from a Web browser client) without using any configuration settings. The service uses special syntax in the .svc file to automatically enable an AJAX endpoint.
AJAX support in WCF is optimized for use with ASP.NET AJAX through the ScriptManager
control. For an example of using WCF with ASP.NET AJAX, see the Ajax Samples.
Note
The setup procedure and build instructions for this sample are located at the end of this topic.
This sample builds upon the AJAX Service Using HTTP POST. As described in the Basic AJAX Service sample, WebScriptServiceHostFactory is used to host the service.
<%ServiceHost
language=c#
Debug="true"
Service="Microsoft.Ajax.Samples.CalculatorService
Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"
%>
WebScriptServiceHostFactory automatically adds a WebScriptEndpoint to the service. If no configuration changes need to be made to the endpoint, the <system.ServiceModel>
section can be completely removed from the Web.config file for the service. The Web.config file contains some ASP.NET settings, which are used by ConfigFreeClientPage.aspx. If that were not the case, the entire Web.config file could be removed.
To set up, build, and run the sample
Ensure that you perform the setup instructions in One-Time Setup Procedure for the Windows Communication Foundation Samples.
Build the solution ConfigFreeAjaxService.sln as described in Building the Windows Communication Foundation Samples.
Navigate to
http://localhost/ServiceModelSamples/ConfigFreeClientPage.aspx
(do not open ConfigFreeClientPage.aspx in the browser from within the project directory).
Note
When running this sample, please ensure that Anonymous Authentication and Windows Authentication are not enabled simultaneously for the ServiceModelSamples folder in IIS. If that is the case, please disable Windows Authentication. Once you have run the sample, enable Windows Authentication and run "iisreset".