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

Overview

Microsoft released a Windows Update for IIS 7 on 12/29/2011 that causes large web pages to report an error. As a result, the following error can occur in StudyTRAX on pages with a large number of variables:

click to enlarge

Resolution

Add a setting to the web.config file to allow larger web pages. There are two methods to accomplish this: Through the Internet Information Services (IIS) Manager screens or by directly editing the web.config file.

Modifying the web.config file will cause the application to restart. All current sessions will be closed causing the users to loose their work. It is recommended that this step is peformed when no users are logged in.

Method 1: Through IIS Manager (recommended)
  1. Open Internet Information Services (IIS) Manager.
  2. Select the StudyTrax application (in the tree in the panel on the right).
  3. In the Features View, under the ASP.Net section, double click on Application Setting (See Figure 1).
  4. In the panel on the right, click in the Add button.
  5. In the dialog that come up, enter aspnet:MaxHttpCollectionKeys for the Name and 50000 for the Value (See Figure 2).
  6. Click on the OK button.

Figure 1 (click to enlarge)

Figure 2 (click to enlarge)

Method 2: Directly edit the web.config file

The web.config file is located in the StudyTrax application's root directory. To determine the root directory, open Internet Information Services (IIS) Manager, select the StudyTRAX application (in the tree in the panel on the right), and click on Basic Settings (in panel on the right). The Physical Path in dialog that comes up contains the StudyTRAX application's root directory.

click to enlarge

StudyTRAX v3.0

Edit the web.config file. In the <appSettings> element add the following line below. If there is no <appSettings> element, follow the steps for StudyTRAX v3.1

<add key="aspnet:MaxHttpCollectionKeys" value="50000" />
StudyTRAX v3.1 and v3.2

Add the following <appSettings> element under the <configuration> element. Ensure that <appSettings> is a direct child of configuration and not a child of another element.

<appSettings>
	<add key="aspnet:MaxHttpCollectionKeys" value="50000" />
</appSettings>

References

Microsoft Knowledge Base article about this issue
More in depth explanation