MvcOptions.MaxValidationDepth MvcOptions.MaxValidationDepth MvcOptions.MaxValidationDepth Property

Definition

Gets or sets the maximum depth to constrain the validation visitor when validating. Set to null to disable this feature.

ValidationVisitor traverses the object graph of the model being validated. For models that are very deep or are infinitely recursive, validation may result in stack overflow.

When not null, ValidationVisitor will throw if traversing an object exceeds the maximum allowed validation depth.

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 value of the 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_2 then this setting will have the value 200 unless explicitly configured.

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

public Nullable<int> MaxValidationDepth { get; set; }
member this.MaxValidationDepth : Nullable<int> with get, set
Public Property MaxValidationDepth As Nullable(Of Integer)

Property Value

Applies to