Actionresult vs JSONresult

ActionResult is an abstract class that an action can return. The helper methods in Controller (eg, Json(), Content(), View(), …) return different concrete classes that inherit ActionResult, including JsonResult. You should declare your action methods as returning ActionResult, so that they have the freedom to return any concrete result class.

How to unit test an Action method which returns JsonResult?

I know I’m a bit late on this guys, but I found out why the dynamic solution wasn’t working: JsonResult returns an anonymous object and these are, by default, internal, so they need to be made visible to the tests project. Open your ASP.NET MVC application project and find AssemblyInfo.cs from folder called Properties. Open … Read more

Using JSON.NET as the default JSON serializer in ASP.NET MVC 3 – is it possible?

I believe the best way to do it, is – as described in your links – to extend ActionResult or extend JsonResult directly. As for the method JsonResult that is not virtual on the controller that’s not true, just choose the right overload. This works well: protected override JsonResult Json(object data, string contentType, Encoding contentEncoding) … Read more