Microsoft KB Archive/812399

= FIX: &quot;The view state is invalid for this page and might be corrupted&quot; error message when the view state contains objects that have long decimals in the .NET Framework 1.0 =

Article ID: 812399

Article Last Modified on 10/11/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition
 * Microsoft .NET Framework 1.0

-



SYMPTOMS
When you open a page that contains numeric data in the View State, if the numbers are very small, for example five places past the decimal place (0.00004) you recieve a View State error message similar to the following:

Server Error in '/vState2' Application. The View State 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 View State 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 View State is invalid for this page and might be corrupted.] System.Web.UI.Page.LoadPageStateFromPersistenceMedium +150 System.Web.UI.Page.LoadPageViewState +16 System.Web.UI.Page.ProcessRequestMain +421



CAUSE
This problem occurs because the .NET Framework converts small numbers in the View State to Scientific Notation. When the .NET Framework tries to deserialize the number, it cannot recognize the number or the number is not the expected data format.



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 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:

http://support.microsoft.com/contactus/?ws=support

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 -  01-Nov-2002  17:47  1.0.3705.370    196,608  Aspnet_isapi.dll 01-Nov-2002 17:47  1.0.3705.370      4,169  Aspnet_perf.h   01-Nov-2002  17:47  1.0.3705.370     20,468  Aspnet_perf.ini 01-Nov-2002 17:47  1.0.3705.370     20,342  Aspnet_perf2.ini 01-Nov-2002 17:47  1.0.3705.370     28,672  Aspnet_wp.exe 16-Oct-2002 17:22  1.0.3705.288         15  SmartNav.htm 18-Oct-2002 11:03  1.0.3705.288      8,800  SmartNav.js   16-Oct-2002  17:22  1.0.3705.288      7,003  SmartNavIE5.js   01-Nov-2002  17:47  1.0.3705.370  1,191,936  System.Web.dll



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



Steps to Reproduce the Behavior
To reproduce the problem, follow these steps:   Paste the following code in a new file named Viewstate.aspx, and then save the file to the root Web of a server running Internet Information Services (IIS): 

[Serializable] public class myObjects {       internal object _stepPrice; public object StepPrice { get { return _stepPrice; } } }

public void Page_Load(Object sender, EventArgs E) { if (!IsPostBack) {       myObjects m1 = new myObjects; myObjects m2 = new myObjects; decimal tmp1 = 0.09194m; //This can be reproduced if these values are less than 0.0001. Otherwise, it works as expected. decimal tmp2 = 0.01m; m1._stepPrice= (object)tmp1; m2._stepPrice= (object)tmp2;

object[] hello ={m1,m2}; ViewState[&quot;MyObj&quot;]=hello; } }

public void Submit_Click(Object sender, EventArgs E) { object hello; hello = (object) ViewState[&quot;MyObj&quot;]; }

   In the browser, view the page (http://localhost/Viewstate.aspx). Click Submit. (No error occurs.)  Change the following lines of code in the file, and then save the file:

From decimal tmp1 = 0.09194m; decimal tmp2 = 0.01m; To decimal tmp1 = 0.00009194m; decimal tmp2 = 0.00001m; </li> Close the browser.</li> Open the browser again, and then view the page again. Click Submit.</li></ol>

Keywords: kbbug kbfix kbproperties kbqfe kbwnet kbnetframe100presp3fix kbvs2002sp1sweep kbhotfixserver KB812399

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.