ValidateModel Method (Object, String)
Collapse the table of content
Expand the table of content

Controller.ValidateModel Method (Object, String)

.NET Framework 4

Validates the specified model instance using an HTML prefix.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

protected internal void ValidateModel(
	Object model,
	string prefix


Type: System.Object
The model to validate.
Type: System.String
The prefix to use when looking up values in the model provider.

When a model is being validated, all validators for all properties are run if at least one form input is bound to a model property.

The ValidateModel is like the method TryValidateModel except that the TryValidateModel method does not throw an InvalidOperationException exception if the model validation fails.

For more information model validation, see the entry Input Validation vs. Model Validation in ASP.NET MVC on Brad Wilson's blog.

Community Additions

© 2015 Microsoft