Post

.NET 4 - ThrowIfMaxHttpCollectionKeys

I got a bug through on one of our applications the other day, the user said the system kept on crashing on them. When I checked the error log the inner exception coming through was

1
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()

Now the form has a lot of dynamic fields in it and has the capacity to get quiet big. What I hadn’t realised was that a form is limited to 1000 fields for submission currently. This was a update to .Net 4, you can read more here if that interests you. Anyway the fix is to extend the MaxHttpCollectionKeys value in the web.config appSettings as below:

1
<add key="aspnet:MaxHttpCollectionKeys" value="2000" />

And now the form can have up to 2000 fields. Problem solved.

This post is licensed under CC BY 4.0 by the author.