Asp.net core model doesn't bind from form

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

    Be careful not to give an action parameter a name that is the same as a model property or the binder will attempt to bind to the parameter and fail.

    public async Task Index( EmailModel email ){ ... }
    
    public class EmailModel{ public string Email { get; set; } }
    

    Change the actions parameter 'email' to a different name and it will bind as expected.

    public async Task Index( EmailModel uniqueName ){ ... }
    

提交回复
热议问题