Represents the exception that is thrown when the view state cannot be loaded or validated. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
If an exception occurs when the page loads the view-state information, the page creates a object and passes it as an inner exception within an HttpException exception. The HttpException exception is re-thrown to be handled by the application.
The class stores information about the exception in the Message property. If the request has permission to access the ServerVariables property, then the Message property contains the values returned from the RemoteAddress, RemotePort, UserAgent, PersistedState, Referer, and Path properties; otherwise, the Message property contains a generic view-state error message.
A view-state exception can be the result of a Message Authentication Codes (MAC) validation error. If the page attribute enableViewStateMac is set to true, view-state information is encoded with a MAC identifier. When the view-state information is posted back to the server, the page verifies the encoding to ensure that it has not been altered by the user. If the page cannot validate the MAC encoding on the view-state information, it will throw an HttpException exception with the object as an inner exception.
For MAC validation to succeed, the view-state information must be hashed by the same key when it is sent and received. Within a Web farm, the machine key on each server should be set to a common key.
The following code example demonstrates how to implement a method that deserializes a base64-encoded string and returns an ICollection collection of property settings. The Deserialize method can throw an HttpException exception that contains a object as an inner exception. The example shows how you can catch an HttpException exception and retrieve the properties from the object.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.