且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ASP.NET MVC 3 HttpPost行动禁用验证?

更新时间:2023-02-25 18:40:22

我最近有一个类似的问题。我想排除验证一些性质和使用的下列code:

I recently had a similar problem. I wanted to exclude some properties from validation and used the following code:

ModelState.Remove("Propertyname");

要隐藏errormessages可以使用

To hide the errormessages you can use

ModelState.Clear();

但问题是,为什么你提交的值,如果你不使用它们?你会不会更好的使用复位按钮,在表单中的值重置:

But the question is why you submit the values if you do not use them? Would you not better use a reset button to reset the values in the form:

<input type="reset" value="Reset Form">