So Im getting same results whether I use ActionResult or JsonResult in the return type. Whats the difference and when would you use the datacontractJson serializer?
So Im getting same results whether I use ActionResult or JsonResult in the return
Share
JsonResultis a class that inheritsActionResult.It doesn’t matter which one you declare your method as returning.
The
Json()method is a helper method that returns aJsonResult; it’s simpler than writingnew JsonResult { ... }.JsonResultwraps the built-in JSON serializer; it’s much simpler than manually serializing your objects and writing the JSON to the response stream (that’s whatJsonResultdoes for you)