Should my MVC controller really know about JSON?

后端 未结 7 1951
有刺的猬
有刺的猬 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.

    0 讨论(0)
提交回复
热议问题