Home > Career, Technical > How to avoid ‘WebForms.PageRequestManagerServerErrorException’ error

How to avoid ‘WebForms.PageRequestManagerServerErrorException’ error

This error i got suddenly, when i use partial post back to server on Asp.net aspx page. this page was working perfectly for months and today only i got this.  After looking into this sometime, only thing has changed here is now i have more data on the page.  But there is no way to catch the error and visual studio is returning this error when i click any control on the page.

WebForms.PageRequestManagerServerErrorException

When i look on the windows event log, exception was logged there as,

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()

What has happen was because of more data on the page, It is generating  “ThrowIfMaxHttpCollectionKeysExceeded” error.

To overcome this issue you have to add following key to web.config as follows,

<appsettings>
   <add key=”aspnet:MaxHttpCollectionKeys” value=”2000″></add>
</appsettings>

P/S : After looking into this issue on the web, i found this information,

 Microsoft released a security update KB2656356 / MS11-100 for ASP.NET to address a potential Denial of Service vulnerability.  In the update, Microsoft introduced a limit to the number of data elements on an ASP.NET form.   The default limit is 1000 data elements.   Exceeding the limit will cause a ThrowIfMaxHttpCollectionKeysExceeded error.

After applying the patch to your webserver, forms that exceed the limit will generate the following error when posting:

Advertisements
Categories: Career, Technical
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s