Tuesday, 31 December 2013

Adding ASP.NET AJAX endpoint without Configuration

WCF allows us to create a service that exposes an ASP.NET AJAX-enabled Endpoint that can be called from JavaScrit on Client Website.

To create an such endpoint either use configuration file Or use without Using Configuration element.
In this Post am going to Explain about the Adding Ajax end point Without Configuration Element.

In this scenarion Service Must be Hosted in IIS(Internet Information Services).To activate an ASP.Net AJAX endpoint Using this approach, specify the WebScriptServiceHostFactory as the Factory Parameter in the Service host Directive in the .svc file

This Automatically configures an ASP.NET AJAX endpoint so that it can called from Javascript on a Clent Side

Adding the Factory configuration.

<%@ ServiceHost Language="C#" Debug="true" Service="Acsellerate.WebServices.TestService" CodeBehind="TestService.svc.cs" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>

Build the Service and Call the Service from the Javascript.

If your service requires ASP.NET Compatibility Mode.
if it uses the HttpContext class or ASP.Net authorization mechanisms.we need to turn on the this mode in the configuration file. the Configuratuion Element required is the
which must added.

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

References: msdn