Disable Model Validation in Asp.Net MVC

前端 未结 7 975
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 20:41

How do I disable Model validation for a single Action in a Controller ? Or can I do it per model by registering the model type at startup somewhere ?

I want the Mode

7条回答
  •  情书的邮戳
    2020-12-09 21:27

    Just remove the items you don´t need before checking if the model is valid

    ModelState.Remove("Email");
    if (ModelState.IsValid)
    {
       // your logic
    }
    

提交回复
热议问题