Hi,
Today, I saw that ASP.NET Web API now has [JsonResult](https://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.Http/Results/JsonResult.cs) and even a Json method on ApiController. Just what we needed all along! I cannot think of any words which would describe my reaction when I saw it but maybe this picture can give a hint: [http://i.imgur.com/Bp9an.gif](http://i.imgur.com/Bp9an.gif)
Why on God's green earth do we have this? Why do we try to mess with HTTP and beautiful content negotiation that ASP.NET Web API framework has? This's harm! Please, just remove it and it will be nothing but a commit history.
Thanks!
Comments: @Darrel I think I explained myself not clearly. I'm not saying the action method is not responsible for creating the object but IMHO, the action method shouldn't state the format of the output. It should delegate that work to a singleton service (IContentNegotiator implementation). That's what CreateResponse is exactly doing. If you really know what you are doing, have the Json method on the ApiController but people will use this regardless (I'm sure) and we will have handicapped APIs all over the place. I personally don't want the efforts to be spent on these useless features. What I would rather want is for the Web API framework to have a really nice story on API versioning (through a custom header, Accept header, etc.) with minimum code duplication; T4 templates for creating a .NET client wrapper for your HTTP API; have a built-in way for hypermedia-driven APIs. Instead of moving away from the beautiful semantics of the HTTP, let's move the framework towards the its goodness.
Today, I saw that ASP.NET Web API now has [JsonResult](https://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.Http/Results/JsonResult.cs) and even a Json method on ApiController. Just what we needed all along! I cannot think of any words which would describe my reaction when I saw it but maybe this picture can give a hint: [http://i.imgur.com/Bp9an.gif](http://i.imgur.com/Bp9an.gif)
Why on God's green earth do we have this? Why do we try to mess with HTTP and beautiful content negotiation that ASP.NET Web API framework has? This's harm! Please, just remove it and it will be nothing but a commit history.
Thanks!
Comments: @Darrel I think I explained myself not clearly. I'm not saying the action method is not responsible for creating the object but IMHO, the action method shouldn't state the format of the output. It should delegate that work to a singleton service (IContentNegotiator implementation). That's what CreateResponse is exactly doing. If you really know what you are doing, have the Json method on the ApiController but people will use this regardless (I'm sure) and we will have handicapped APIs all over the place. I personally don't want the efforts to be spent on these useless features. What I would rather want is for the Web API framework to have a really nice story on API versioning (through a custom header, Accept header, etc.) with minimum code duplication; T4 templates for creating a .NET client wrapper for your HTTP API; have a built-in way for hypermedia-driven APIs. Instead of moving away from the beautiful semantics of the HTTP, let's move the framework towards the its goodness.