Returning JSON from WCF Web API

WCF Web API is Microsoft's answer for creating RESTful services. Currently it is in preview state and you can download the binaries from here. For the people who are not aware of RESTful services, a RESTful service is a simple web service implemented using HTTP and that can be communicated using the normal GET, POST and other HTTP methods. Exposing a class as a RESTful service makes it easily accessible by wide variety of browsers and devices. In WCF Web API the REST service class is typically called as a resource and the format in which they exchange data is called as media type (ex. XML, JSON etc).

The WCF Web API uses the same routing module used in ASP.NET MVC to route the incoming requests to particular service class methods. In this small article I’m going to tell you how we can make the service to return data in JSON media-type.

Continue Reading