Search code examples
asp.netexceptionviewstatecitrix

The state information is invalid for this page and might be corrupted, was working now not (under Citrix)


I have a customer who has just reported an error with a ASP.Net web application. They run it via Citrix, and it has run just fine for years. After a recent update, which wouldn't have changed anything remotely related to viewstate they have started getting the following error:

System.Web.HttpException: The state information is invalid for this page and might be corrupted.
---> System.Web.UI.ViewStateException: Invalid viewstate.
 Client IP: ...
 Port: 4191
 User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
 ViewState: 822106
 Referer: http://....
 Path: /...aspx
---> System.FormatException: Invalid length for a Base-64 char array.
at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded()

Note the weird viewstate - 822106. This should look something like /wEPDwUJLTc4OTg3Mjg4D2Q....(etc). They gave me an IP address so I could go in and test directly (via a VPN) and everything worked perfectly. However I wasn't running it via Citrix when doing this. I switched off viewstate via setting the following:

<pages enableViewState="false" enableViewStateMac="false">

in the web.config but this made no difference. The odd thing is it had worked for years. Any and all suggestions hugely welcomed.


Solution

  • At the top of your .aspx page, in the @page directive, add the ValidateRequest property and set to false.

    I would only recommend this on Intranet applications though, as it opens a security hole. You can disable MAC messages the same way, by using the EnableViewStateMac property. This may help:

    http://support.microsoft.com/en-us/kb/2915218