Megosztás a következőn keresztül:


MvcOptions.AllowValidatingTopLevelNodes Property

Definition

Gets or sets a value that determines if model bound action parameters, controller properties, page handler parameters, or page model properties are validated (in addition to validating their elements or properties). If set to true, BindRequiredAttribute and ValidationAttributes on these top-level nodes are checked. Otherwise, such attributes are ignored.

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

Property Value

The default value is true if the version is Version_2_1 or later; false otherwise.

Remarks

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_0 then this setting will have the value false unless explicitly configured.

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

Applies to