Asp.net-mvc – Actionresult vs JSONresult

asp.net-mvcasp.net-mvc-3asp.net-mvc-4asp.net-mvc-5jsonresult

I have 2 questions:

  1. What is the difference between JSONResult and ActionResult?

  2. When to use JSONResult in MVC?

Best Answer

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.