2 typical samples:
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult Create()
{
return PartialView();
}
Why do they not return the most appropriate type like ViewResult and PartialViewResult?
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.
Of course they can have a
ViewResultorPartialViewResultreturn type in this case. But what benefit exactly would it give to you? What if later you decide that in some case (e.g. when the request comes from an Ajax call) you want to returnJsonResult?You typically do not handle the return value of an action method yourself. It’s processed behind the scenes by the MVC framework, so you really don’t care about the signature.