Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The "Viewstate is invalid for this page" error message does not provide sufficient information to troubleshoot the issue


View products that this article applies to.

Summary

Because View State data is stored in a hidden field on a Web page, it is vulnerable to tampering when data is being transferred between the client and the server. To help make the View State feature more secure, Microsoft ASP.NET validates the View State data to verify that it came from the correct page.

If ASP.NET cannot validate the View State data, ASP.NET returns a message to the client browser that states that "the viewstate is invalid for this page and might be corrupted." However, the message does not describe why the View State data is not valid.

For more information about the View State feature, see "" in the "More Information" section.

↑ Back to the top


Resolution

Although this article offers a hotfix, this hotfix does not fix View State data errors. This hotfix only provides additional information to help you troubleshoot View State data errors.

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 Microsoft .NET Framework 1.0 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone 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 hotfix has the file attributes (or later file attributes) 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
   --------------------------------------------------------------
   11-Dec-2003  07:13  1.0.3705.478    200,704  Aspnet_isapi.dll
   11-Dec-2003  07:06                    4,169  Aspnet_perf.h
   11-Dec-2003  07:14                  513,302  Aspnet_perf.ini
   11-Dec-2003  07:14                  510,714  Aspnet_perf2.ini
   11-Dec-2003  07:14  1.0.3705.478     24,576  Aspnet_regiis.exe
   11-Dec-2003  07:14  1.0.3705.478     28,672  Aspnet_wp.exe
   11-Dec-2003  06:27  1.0.3705.478     69,632  Corperfmonext.dll
   17-Jun-2003  21:43                   16,597  Installpersistsqlstate.sql
   17-Jun-2003  21:43                   17,331  Installsqlstate.sql
   09-Sep-2003  00:28                   17,807  Installsqlstatetemplate.sql
   11-Dec-2003  06:25  1.0.3705.478    303,104  Mscorjit.dll
   11-Dec-2003  23:48  1.0.3705.478  1,953,792  Mscorlib.dll
   11-Dec-2003  06:18                   10,284  Mscorlib.ldo
   11-Dec-2003  06:26  1.0.3705.478  2,273,280  Mscorsvr.dll
   11-Dec-2003  06:26  1.0.3705.478  2,269,184  Mscorwks.dll
   11-Dec-2003  07:10  1.0.3705.478     20,480  Perfcounter.dll
   23-Aug-2002  02:23                       15  Smartnav.htm
   30-Jul-2003  00:04                    8,728  Smartnav.js
   11-Dec-2003  23:48  1.0.3705.478  1,179,648  System.data.dll
   11-Dec-2003  23:48  1.0.3705.478  1,695,744  System.design.dll
   11-Dec-2003  23:48  1.0.3705.478  1,175,552  System.dll
   11-Dec-2003  23:48  1.0.3705.478    241,664  System.messaging.dll
   11-Dec-2003  23:48  1.0.3705.478    311,296  System.runtime.remoting.dll
   11-Dec-2003  23:49  1.0.3705.478    131,072  System.runtime.serialization.formatters.soap.dll
   11-Dec-2003  23:48  1.0.3705.478  1,200,128  System.web.dll
   11-Dec-2003  23:48  1.0.3705.478    507,904  System.web.services.dll
   11-Dec-2003  23:50  1.0.3705.478  1,994,752  System.windows.forms.dll
   11-Dec-2003  07:20                   16,632  System.windows.forms.ldo
   11-Dec-2003  07:15  1.0.3705.478     57,344  System.windows.forms.tlb
   11-Dec-2003  23:50  1.0.3705.478  1,302,528  System.xml.dll
   11-Dec-2003  23:47  1.0.3705.478     32,768  Tlbimp.exe
   17-Jun-2003  21:43                    1,419  Uninstallpersistsqlstate.sql
   09-Sep-2003  00:28                    2,119  Uninstallsqlstatetemplate.sql
   11-Dec-2003  23:47  1.0.3705.478     65,536  Wsdl.exe

Hotfix details

This hotfix causes the View State error messages to contain more information. After you apply this hotfix, the View State error message title becomes "Unable to Validate Data." Although the new error message format does not describe exactly what the problem is, it provides more information than the earlier message format.

Note To obtain more information about the status of your View State data, you can run the View State information that appears in the error message through a third-party View State decoder.

This hotfix sets the InnerException property on the HttpException object so that you can use the Application_Error method to log the underlying exception. Make sure that you recursively log all InnerException property errors.

This hotfix adds the following specific information about the client to the error message for View State errors:
  • IP address
  • Port number
  • User-Agent
  • Value of the View State
  • Http-Referer
  • Path of the requested page
If the error occurs while ASP.NET is verifying the View State message authentication code (MAC), this hotfix adds a message in the stack trace that prompts you to verify the <machineKey> settings. The error message also notes that the View State data can only be posted back to the same page.

If the error occurs during deserialization, this hotfix adds the LosFormater token, the _deserializationData token, and the position where the error occurred to the error message.

In most cases, if the View State data has been truncated, the View State feature will experience a FormatException error in the FromBase64String method and you will receive the following error message:
Invalid length for a Base-64 char array
However, if the View State data has been truncated and is still base64-encoded, the error will occur later in the code.

View State error message before you install this hotfix

Server Error in '/ViewState' Application.
--------------------------------------------------------------------------------
The viewstate is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The viewstate is invalid for this page and might be corrupted.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The viewstate is invalid for this page and might be corrupted.]
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +151
System.Web.UI.Page.LoadPageViewState() +18
System.Web.UI.Page.ProcessRequestMain() +423

View State error message after you install this hotfix

Server Error in '/ViewState' Application.
--------------------------------------------------------------------------------

Unable to validate data.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Unable to validate data.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): Unable to validate data.]
System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, String strModifier) +866
System.Web.UI.LosFormatter.Deserialize(String input) +44

[HttpException (0x80004005): Authentication of viewstate failed. 1) If this is a cluster, edit <machineKey> configuration so all servers use the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. 2) Viewstate can only be posted back to the same page. 3) The viewstate for this page might be corrupted.]
System.Web.UI.LosFormatter.Deserialize(String input) +102
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +101

[HttpException (0x80004005): The viewstate is invalid for this page and might be corrupted.
Client IP: 127.0.0.1
Port: 1095
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
ViewState: dDwzNDM3NTkwMzg7dDw7bDxpPDEPGk8MT47PjtsPHQ8QDA8cDxwPGw8RGF0YUt
Http-Referer: http://localhost/Connect2Access/WebForm1.aspx
Path: /connect2access/webform1.aspx.]
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +435
System.Web.UI.Page.LoadPageViewState() +16
System.Web.UI.Page.ProcessRequestMain() +439
Note The ViewState value in this sample error message has been truncated to fit the context of this article.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


More information

For more information about the terminology that is used to describe Microsoft product updates, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates

Description of the View State feature

ASP is stateless. Every time that an application makes a round trip from the server to the client, the data is not intrinsically saved. Every time that a Web page is posted to the server, the page is re-created. This behavior causes all information that is associated with the page, and with the controls on the page, to be lost for each round trip. For example, if a user types information in a text box, that information is lost in the round trip from the browser or from the client device to the server.

ASP.NET is also stateless. However, ASP.NET has a new feature, View State, that you can use to preserve data between round trips to and from the server. View State automatically preserves property values of the page, and the values of all controls on the page, between round trips. The View State data is maintained as a hidden field on the page.

You can use the View State feature to store your own page-specific values across round trips when the page posts back to itself. For example, if your application is maintaining user-specific information, you can use the View State feature to store this user-specific information. User-specific information is information that is used on the page but that is not necessarily a part of any control.

back to the "Summary" section

Description of the View State MAC feature

The View State message authentication code (MAC) is an authentication tag (also known as a checksum) that is created when you apply an authentication scheme, together with a secret key, to a message. A MAC is computed and verified by using the same key. Therefore, a MAC can only be verified by the intended receiver. MACs can be created by using various cryptographic techniques and algorithms, such as the Secure Hash Algorithm (SHA), the Message Digest 5 (MD5) algorithm, or the Data Encryption Standard (DES) algorithm.

The View State MAC feature is intended to prevent a client from sending a request that contains malicious View State data. By default, the View State MAC feature is enabled by using the enableViewStateMac="true" flag in your Machine.config file.

The simplest way to determine whether the issue that you are experiencing is related to the MAC is to turn off the feature. To do this, set the enableViewStateMac flag to false. If you no longer experience View State errors, the problem related to the MAC.

The View State MAC is applied differently in the Microsoft .NET Framework 1.0 before hotfix 323744 is installed. The hotfix that this article describes (hotfix 832183) includes hotfix 323744. If you do not install hotfix 323744 - alone or with hotfix 832183 - on all the other computers in the environment also, the computers that do not have hotfix 323744 installed will experience View State data errors.

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
323744 FIX: "The View State Is invalid for this page and might be corrupted" error message in ASP.NET
328546 INFO: Post-Service Pack 2 .NET Framework ASP.NET Hotfix Package

↑ Back to the top


Keywords: kbhotfixserver, kbvs2002sp1sweep, kbstate, kbnetframe100presp3fix, kbfix, kbbug, kbqfe, KB832183

↑ Back to the top

Article Info
Article ID : 832183
Revision : 5
Created on : 4/7/2006
Published on : 4/7/2006
Exists online : False
Views : 497