In ASP.NET MVC 3, which is more correct to use: Json() or new JsonResult()? Either returns the same result. Thanks for helping solve an office debate.
In ASP.NET MVC 3, which is more correct to use: Json() or new JsonResult()
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Json()is just an extension method that actually returns aJsonResultobject behind the scenes (rather than needing to call the constructor directly).I almost always use the Extension Method myself. This keeps more in line with the other common return types from Action Methods like
View(),PartialView(), etc.I also make sure to create an extension method for any custom ActionResult types that I create. In the end it’s a matter of personal preference.