1

Background

I have inherited an ASP.NET web application project that has been passed on for the last 6-7 years. The site is running on .NET 2.0 and IIS 7.5 on my development machine and IIS 6.0 on the production server. A further snag to this is that I can not change or refactor the page into smaller fragments. The usual office politics apply, client will not pay for it, no time to do it, resources stretched as is..

Problem

There is one page that has an ASP:Table server control that literally generates hundreds on textboxes.

I have noticed that when it reaches a certain amount of rows that an IIS exception is thrown:

Local Development Machine (IIS 7.5, .NET 2.0)

HTTP Error 400.0 - Bad Request

ASP.NET detected invalid characters in the URL. ..ErrorPage.aspx?ErrorMsg=The+URL-encoded+form+data+is+not+valid.

Production (IIS 6.0, .NET 2.0)

Operation is not valid due to the current state of the object

I have searched around for a couple of hours and I have come across a couple of threads e.g. Operation is not valid due to the current state of the object. when i select dropdown list

I have tried inserting the following AppSettings (shown below) in my Web.config and cannot get this issue resolved:

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

Does anyone have any ideas what I can do to fix this issue or get the above settings to take affect?

Thanks in advance.

Community
  • 1
  • 1
Seany84
  • 5,526
  • 5
  • 42
  • 67
  • It could be (and it's hard to know without seeing the page) that your huge number of checkboxes are generating an equally huge viewstate - this could be exceeded the max request length or similar when you post back, or the form is simply truncated. Is the ViewState large? – dash Aug 01 '12 at 22:16
  • 1
    Since your question states that you are generating hundreds of controls per page... http://blogs.msdn.com/b/oldnewthing/archive/2007/03/01/1775759.aspx – Jupaol Aug 01 '12 at 22:19
  • @dash I really can't post the code. Mainly because it's monolithic and enormous. The viewstate is ~ 20,000 characters in length. – Seany84 Aug 01 '12 at 22:20
  • @Jupaol Yes I agree, this is not my code or design. To make things even more frustrating I can not touch the code to refactor etc until we get a purchase order/change request. That's why I'm asking the community for help at 23:22 at night :) – Seany84 Aug 01 '12 at 22:22
  • I've heard stories about certain browsers not posting the entirety of large form fields (which, of course, includes ViewState). Do you need ViewState on the page [chances are you do] because if you don't then you could try turning it off. – dash Aug 01 '12 at 22:24
  • Yeah that sucks... One question are you using query string? – Jupaol Aug 01 '12 at 22:25
  • @dash - Yep ViewState is there to stay I'm afraid. – Seany84 Aug 01 '12 at 22:36
  • @Jupaol - No, there's no use of the QueryString. – Seany84 Aug 01 '12 at 22:36

0 Answers0