I used this below code on my asp.net controller to return Json object on my Ajax on javascript
public JsonResult myMethod()
{
// return a Json Object, yo
ASP.NET Web API works with a little bit different philosophy. You should return just an entity (or set of entities) and it is up to content negotiation mechanism to return it to the client in the format which he has requested. You can read more about content negotiation here:
You can of course bypass the content negiotiation by returning a HttpResponseMessage
. In this case yo need to serialize the object into JSON yourself (basics of this approach are also described in the article mentioned above).