Share via


MvcJsonOptions.AllowInputFormatterExceptionMessages Property

Definition

Gets or sets a flag to determine whether error messages from JSON deserialization by the JsonInputFormatter will be added to the ModelStateDictionary. The default value is false, meaning that a generic error message will be used instead.

public:
 property bool AllowInputFormatterExceptionMessages { bool get(); void set(bool value); };
public bool AllowInputFormatterExceptionMessages { get; set; }
member this.AllowInputFormatterExceptionMessages : bool with get, set
Public Property AllowInputFormatterExceptionMessages As Boolean

Property Value

Remarks

Error messages in the ModelStateDictionary are often communicated to clients, either in HTML or using BadRequestObjectResult. In effect, this setting controls whether clients can receive detailed error messages about submitted JSON data.

This property is associated with a compatibility switch and can provide a different behavior depending on the configured compatibility version for the application. See CompatibilityVersion for guidance and examples of setting the application's compatibility version.

Configuring the desired of the value compatibility switch by calling this property's setter will take precedence over the value implied by the application's CompatibilityVersion.

If the application's compatibility version is set to Version_2_0 then this setting will have value false unless explicitly configured.

If the application's compatibility version is set to Version_2_1 or higher then this setting will have value true unless explicitly configured.

Applies to