You are here
Home > ASP.NET

ThrowIfMaxHttpCollectionKeysExceeded Exception

In an asp.net application having an HTML form in which a user has option to select objects (e.g in a salesforce data transfer utility a user has the option to select salesforce objects to transfer data from production to sandbox) by using check boxes to send data to the server through post. Asp.net would throw an exception if Max Keys (Objects in our case) exceeds 1000. See below for exception details

System.Web.HttpException: The URL-encoded form data is not valid. ---> System.InvalidOperationException: Operation is

not valid due to the current state of the object.
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
   at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)
   at System.Web.HttpRequest.FillInFormCollection()

In order to prevent this from happening web.config needs some adjustment. Microsoft has restricted this no. to 1000 to prevent DOS attacks

Solution is to increase this limit to 2000, see below

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

Get Free Email Updates!

Signup now and receive free offers, discounts & coupon codes

I agree to have my personal information transfered to Mad Mimi ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Leave a Reply

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Top