Share via


Exposing JSON endpoint for DomainService on WCF Ria Services

1. Make sure you have the WCF Ria Services Toolkit installed.

2. In the Web project, add a reference to %ProgramFiles(x86)%\Microsoft SDKs\RIA Services\v1.0\Toolkit\Libraries\Server\Microsoft.ServiceModel.DomainServices.Hosting.dll

3. Edit the Web.config and add the following to the <configuration> section

<configuration>
  <configSections>
<sectionGroup name="system.serviceModel">
<section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" requirePermission="false" />
</sectionGroup>
</configSections>
 ...

 and the following to the <system.serviceModel> section:

 <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
            multipleSiteBindingsEnabled="true" />
      <domainServices>
        <endpoints>
<add name="JSON" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</endpoints>

      </domainServices>

Done.  Now you can open the json endpoint like this: https://localhost:27525/SilverlightApplication1-Web-DomainService1.svc/json

The endpoints node also support other actions, such as "add" and "remove".  You can also add other endpoints, such as soap and xmljson,  in the same way or remove the default "binary" endpoint.