AJAX Service Without Configuration
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.
The setup procedure and build instructions for this sample are located at the end of this topic.
<%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.
The samples may already be installed on your computer. Check for the following (default) directory before continuing.
If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.
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).
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".