Home > database >  Is there a maximum number of inputs that a Razor Pages page can process on a Post Request?
Is there a maximum number of inputs that a Razor Pages page can process on a Post Request?

Time:11-30

I have a page in my .Net 5 Razor Pages site that uses model binding to a collection of complex objects, and so can have a lot of text input boxes - 8 per row, and I have just tested the page with 39 rows on it. When I submit the form, the Post Event handler does not get fired - I just get a 400 error. When I test it with far fewer rows, the post event does get fired as expected with the form values. Is there a maximum number of inputs that a razor page page can process, or form values that it can bind to? I have come across this issue before, but this is a serious limitation if this is the case

CodePudding user response:

The maximum number of values that a form reader can process by default is 1024. You can configure a different limit in ConfigureServices globally:

services.Configure<FormOptions>(options => options.ValueCountLimit = 2000);

Or you can use the RequestFormLimits attribute to configure it for a particular PageModel:

[RequestFormLimits(ValueCountLimit = 5000)]
public class IndexModel : PageModel

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.requestformlimitsattribute?view=aspnetcore-5.0

  • Related