Should my MVC controller really know about JSON?

后端 未结 7 1971
有刺的猬
有刺的猬 2021-01-30 14:51

The JsonResult class is a very useful way to return Json as an action to the client via AJAX.

public JsonResult JoinMailingList(string txtEmail)
{
        // ...         


        
7条回答
  •  北海茫月
    2021-01-30 15:19

    I think you have a valid point - why not delegate the "accepted response types vs. generated response types resolution" to some place where it actually belongs?

    It reminds me of one of the Jeremy Miller's opinions on how to make an ASP.NET MVC application: “Opinions” on the ASP.NET MVC

    In their application, all controller actions have a lean and simple interface - some view model object enters, another view model object leaves.

提交回复
热议问题