Asp.net core model doesn't bind from form

后端 未结 10 888
没有蜡笔的小新
没有蜡笔的小新 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:25

    Change void to ActionResult.

    [HttpPost]
    public ActionResult Index(EmailModel email)
    

    And don't forget verifying AntiForgeryToken from your view and action.

    // to your form in view 
    @Html.AntiForgeryToken()
    // ------------
    
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Index(EmailModel email)
    

提交回复
热议问题