FIX: "The View State Is Invalid for This Page and Might Be Corrupted" Error Message in ASP.NET


Symptoms


You may receive the following error message in ASP.NET:
The View State is invalid for this page and might be corrupted
You may receive this error message under the following circumstances:
  • Scenario 1: Your ASP.NET application is hosted on a Web farm. A user receives a page that is served by one server but is posted to another server in that Web farm. -or-

  • Scenario 2: You modify your pages, which causes the shadow, copied files in the Temporary ASP.NET files folder to be regenerated. A user has a copy of the page that was requested before this change, and the user posts the page after the files in that folder were regenerated.
NOTE: In Scenario 1, verify that the machine keys match for all of the computers in the Web farm before you apply the hotfix that is listed in the "Resolution" section. This error message occurs if the machine keys do not match. If the machine keys do not match, generate an identical machine key for use in all Web servers before you apply the patch.
For additional information about how to generate these machine keys, click the article numbers below to view the articles in the Microsoft Knowledge Base:
313091 HOW TO: Create Keys by Using Visual Basic .NET for Use in Forms Authentication
312906 HOW TO: Create Keys by Using Visual C# .NET for Use in Forms Authentication

Cause


The case-sensitive value that the TemplateSourceDirectory property of a page returns is used to create and to validate the ViewState property for that page. The value of this property for a page depends on the case-sensitive URL that the first user for that page requested. This value is reused for the remaining requests for that page until that page is recompiled. When the page is recompiled, the TemplateSourceDirectory property is re-initialized. If the new value (which is case-sensitive) differs from the previous value, the ViewState validation from the existing clients fails.

Resolution


A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework service pack that contains this hotfix.


To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

Date Time Version Size File name
--------------------------------------------------------------
29-May-2002 19:18 1.0.3705.284 192,512 Aspnet_isapi.dll
29-May-2002 19:12 19,332 Aspnet_perf.ini
29-May-2002 19:18 1.0.3705.284 24,576 Aspnet_regiis.exe
29-May-2002 19:19 1.0.3705.284 28,672 Aspnet_wp.exe
20-Mar-2002 14:31 8,709 Smartnav.js
20-Mar-2002 14:31 7,003 Smartnavie5.js
29-May-2002 19:28 1.0.3705.284 1,183,744 System.web.dll

This hotfix is also available for the Korean (KOR) version of Microsoft ASP.NET. For additional information about this hotfix, see 323744.

Note The information in this article applies to the Korean version of Microsoft ASP.NET (included with the .NET Framework) 1.0.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

More Information


Steps to Reproduce the Behavior

  1. Create an .aspx page, and then add a Button server control to the page.
  2. Use the following URL to open the page in your browser:
    http://localhost/myweb/page.aspx
  3. Modify the .aspx page so that the page is recompiled.
  4. Open a new instance of the browser.
  5. Use the following URL (notice the difference in the capitalization of "myweb") to open the page in the new instance of the browser:
    http://localhost/MyWeb/page.aspx
  6. Return to the original instance of the browser, and then click Submit. Notice that you receive the error message that is listed in the "Symptoms" section.