Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

MvcOptions.MaxModelBindingCollectionSize Property

Definition

Namespace:
Microsoft.AspNetCore.Mvc
Assembly:
Microsoft.AspNetCore.Mvc.Core.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
Source:
MvcOptions.cs

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.

Applies to


Feedback

Was this page helpful?