I have a form that posts pretty big data and i get this error
[InvalidOperationException: Operation is not valid due to the current state of the object.]
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2419334
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +58
System.Web.HttpRequest.FillInFormCollection() +159
[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +217
System.Web.HttpRequest.get_Form() +104
System.Web.HttpRequest.get_HasForm() +9035903
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
System.Web.UI.Page.DeterminePostBackMode() +69
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +135
To resolve this I got this solution from StackOverflow itself
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>
Now I would like to know the maximum valid value that could be set for aspnet:MaxHttpCollectionKeys
. Is there any problem in setting this key to its max value?
You can see the implementation of MaxHttpCollectionKeys in the aspnetwebstack source on GitHub.
From the implementation it seems like these are the limits:
This MSDN page recommends to not set MaxHttpCollectionKeys to a value too large as that would pose a security risk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With