2

Yesterday we started getting intermittent Invalid Viewstate errors in an ASP.NET website (1.1) that has been running perfectly for the past few years!

System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.Web.HttpException: Invalid_Viewstate Client IP: xxx.xxx.xxx.xxx Port: 55415 User-Agent: UCWEB/2.0 (Linux; U; Adr 4.1.2; en-US; ST27i) U2/1.0.0 UCBrowser/8.7.0.315 U2/1.0.0 Mobile ViewState: dDwyMDMzMzIzOTc5O3Q8O2w8aTwz.....

Http-Referer: http://www.mysite.com/default.aspx Path: /default.aspx. ---> System.FormatException: Invalid length for a Base-64 char array. at System.Convert.FromBase64String(String s) at System.Web.UI.LosFormatter.Deserialize(String input) at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() ....

The strange thing is we haven't made any changes to the code, problems just started on their own.

Have performed all the usual checks such as machine.config validation keys etc.

Finally managed to relieve the problem for desktop browser by turning off ViewStateMac:

<pages enableViewStateMac="False" />

Now in the logs the only browsers reporting the error are mobile browsers although we cannot reproduce the error with any desktop or mobile browsers ourselves :(

UPDATE

Looking through the logs we now suspect the cause of the error are some Windows Updates that were automatically installed yesterday.

Windows Updates that were auto installed 13 February 2014:

http://support.microsoft.com/kb/2898860

http://support.microsoft.com/kb/2901115

Is anybody else seeing Invalid_Viewstate in .net 1.1 since these updates were released?

There is no specific information about what the updates changed from MS.

George Filippakos
  • 16,359
  • 15
  • 81
  • 92
  • .NET 1.1 had several bugs around serialization. It wouldn't surprise me if some of those bugs have been fixed by Windows Update. – John Saunders Feb 14 '14 at 18:45

2 Answers2

2

Never set EnableViewStateMac=false.

The most likely cause of the error you're seeing is that requests are timing out, resulting in an incomplete payload being received by the server. Try bumping the value of <httpRuntime executionTimeout> in Web.config (doc here) if you expect to be dealing with slow clients.

Levi
  • 32,628
  • 3
  • 87
  • 88
1

We're using .NET 4.5, and I just saw the following exception in our web logs.

System.Web.HttpException (0x80004005): The state information is invalid for this page and might be corrupted.
---> System.Web.UI.ViewStateException: Invalid viewstate.
Client IP: [CENSORED]
Port: 52119
Referer: [CENSORED]   Path: [CENSORED] (an ASPX page in our app)
ViewState: [CENSORED]
---> System.FormatException: Invalid length for a Base-64 char array or string.
at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose)
at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded()     --- End of inner exception stack trace ---
at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded()
at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)
at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)
at System.Web.UI.WebControls.HiddenField.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.WebControls.HiddenField.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The user agent was:

User-Agent: UCWEB/2.0 (MIDP-2.0; U; Adr 2.3.5; en-US; TECNO_P3) U2/1.0.0 UCBrowser/9.1.1.420 U2/1.0.0 Mobile

It's not a spider, because the user actually reported the problem to us afterward. I installed the latest Android and iOS (iPad) versions of the browser, and tested our page using a workflow similar to what our logs showed for this user. The result was that the page seemed to work fine. So I am going to go back to the user and suggest that they may need to upgrade their UC Browser to the latest version.

According to http://en.wikipedia.org/wiki/UC_Browser, the browser attempts to improve performance using proxying and cloud compression; I could easily see that interfering with Viewstate if not done carefully. I also found the overall "smell" of the browser to be somewhat spammy, with excessive affiliate/content links, rating solicitation, etc. I will ask our support team to recommend that our user try a more mainstream browser.

Jordan Rieger
  • 3,025
  • 3
  • 30
  • 50