MvcOptions.MaxModelBindingCollectionSize Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the maximum size of a complex collection to model bind. When this limit is reached, the model binding system will throw an InvalidOperationException.
public:
property int MaxModelBindingCollectionSize { int get(); void set(int value); };
public int MaxModelBindingCollectionSize { get; set; }
member this.MaxModelBindingCollectionSize : int with get, set
Public Property MaxModelBindingCollectionSize As Integer
Property Value
The default value is 1024
, matching DefaultValueCountLimit.
Remarks
When binding a collection, some element binders may succeed unconditionally and model binding may run out of memory. This limit constrains such unbounded collection growth; it is a safeguard against incorrect model binders and models.
This limit does not correct the bound model. The InvalidOperationException instead informs the developer of an issue in their model or model binder. The developer must correct that issue.
This limit does not apply to collections of simple types. When CollectionModelBinder<TElement> relies entirely on IValueProviders, it cannot create collections larger than the available data.
A very high value for this option (int.MaxValue
for example) effectively removes the limit and is not recommended.