Asp.net core model doesn't bind from form

后端 未结 10 880
没有蜡笔的小新
没有蜡笔的小新 2021-02-02 13:54

I catch post request from 3rd-side static page (generated by Adobe Muse) and handle it with MVC action.

10条回答
  •  执笔经年
    2021-02-02 14:24

    In my case, I was using the MVC 4.0 convention of naming the object you are posting. E.g.,

    js: $http.post("SaveAnswer", { answer: answerValues })

    C#: public ActionResult SaveAnswer([FromBody] AnswerVM answer) {...}

    When I changed the js to $http.post("SaveAnswer", answerValues), everything works.

提交回复
热议问题