What's the point of ActionResult return type?

后端 未结 3 1203
臣服心动
臣服心动 2021-02-01 23:13

What is the point of an action returning ActionResult?

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 23:39

    Since it is the base class, it allows you to return any of the ActionResult subclasses, such as ViewResult or JsonResult. I typically return ViewResult as the default, but override that behavior if I am dealing with Ajax to return a JsonResult object.

    This allows me to add Ajax as a progressive enhancement and keep the application working without JavaScript and without the need for separate controller actions.

提交回复
热议问题