Share via


ModelStateDictionary.AddModelError Method

Definition

Overloads

AddModelError(String, String)

Adds the specified errorMessage to the Errors instance that is associated with the specified key. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

AddModelError(String, Exception, ModelMetadata)

Adds the specified exception to the Errors instance that is associated with the specified key. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

AddModelError(String, String)

Source:
ModelStateDictionary.cs
Source:
ModelStateDictionary.cs
Source:
ModelStateDictionary.cs

Adds the specified errorMessage to the Errors instance that is associated with the specified key. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

public:
 void AddModelError(System::String ^ key, System::String ^ errorMessage);
public void AddModelError (string key, string errorMessage);
member this.AddModelError : string * string -> unit
Public Sub AddModelError (key As String, errorMessage As String)

Parameters

key
String

The key of the ModelStateEntry to add errors to.

errorMessage
String

The error message to add.

Applies to

AddModelError(String, Exception, ModelMetadata)

Source:
ModelStateDictionary.cs
Source:
ModelStateDictionary.cs
Source:
ModelStateDictionary.cs

Adds the specified exception to the Errors instance that is associated with the specified key. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

public:
 void AddModelError(System::String ^ key, Exception ^ exception, Microsoft::AspNetCore::Mvc::ModelBinding::ModelMetadata ^ metadata);
public void AddModelError (string key, Exception exception, Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata metadata);
member this.AddModelError : string * Exception * Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata -> unit
Public Sub AddModelError (key As String, exception As Exception, metadata As ModelMetadata)

Parameters

key
String

The key of the ModelStateEntry to add errors to.

exception
Exception

The Exception to add. Some exception types will be replaced with a descriptive error message.

metadata
ModelMetadata

The ModelMetadata associated with the model.

Applies to