ViewState error in IE on postback

Celtic

New Member
I'm currently working on an ASP.Net Website running in Sharepoint.Let me just give you some background info before I get to the problem..I develop UserControls which are then added to as webparts on the sharepoint pages.Some of these webparts are loaded dynamically as the sharepoint page loads.This is how we do this:
  • Create an application page (InfoPage) that loads the actual user control into the application page
\[quote\] <form id="frmInfoPage" runat="server"> <div id="infopage" runat="server"></div> </form>\[/quote\]
  • Create an UserControl (InfoContainer) which scrapes the 'InfoPage' and adds it into a div in the 'InfoContainer' using the following code:
<div id="InfoContainerDiv"/> <script language="javascript" type="text/javascript"> var numRando = Math.floor(Math.random() * 101); $("#InfoContainerDiv").load("url of application page"<%=Query%>&rndNum=" + numRando); </script>
  • So then this container is put into the SharePoint page...
So the problem is that when the sharepoint page renders, there will be 3 __VIEWSTATE hidden fields (2 for the dynamically loaded controls and the SP page), which IE7-9 will concatenate with a comma. i.e. /WSteyxeetYRduiylgkdxr,TUIFbiygutifTUfuvFufVvIUCF,ITcvuVuyfIYRCTECOBPOUIBHvThis causes an error on postbacks when the server tries to decode the ViewState:\[code\]<pre lang="HTML">The state information 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 state information 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: [FormatException: Invalid character in a Base-64 string.] System.Convert.FromBase64String(String s) +0 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +98 System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded() +205[ViewStateException: Invalid viewstate. Client IP: 10.0.0.2 Port: 52270 User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) ViewState: /wEWOAKyz/ClDQKu1K/fBQLCl57WAQL2s5oZArGPqIAOAp20leQEArOq47oIAuqkk+UGArr75pUEAo3A5PMBAq/69ZkHAqTPzZIBArKB/tECAund0sECAoOVssUPAsbZv7cGAtKIwsUDAqzJytwCAvLwypMPApedlMsPAsb2uIYDAqq989YCAoyOwIYBAurogPQDAqb55aEOApWatccBArCN1+wLAvqjl7IPAsbemgcCq+T48Q0CnKjesQwCt4PAxgYCgumAmA4CgumEmA4CvcCmLQL6o5uyDwK9wKItAqvk/PENAsbengcC4bGArAoC4bG8rAoCnKiisQwCmZKdzAIC2tuR7gICk7OHrQYCvZqnwAEChe3tiAECq5rv3AIC69aW+gkCsaHYzAgC2/SjjgwCoprfugkC98TR6AwCho29jgcC3LrdswwChpymvwM=,/wEWAwLv25y/BQLPi+juDQK8wrfPAQ==,/wEWEQLv25y/BQKV1/6iBwL5ivP7BgKF5rW2DgLkv7KzBQKt56yyBwL0x6mvBgK35/ixAQL23cvUDgLk5ryLCgKfw/3jDAL7wZyxBgKosZu6CAK66OGUCQKHyrWLCQLUyPmPCQKBpr2SCQ== Referer: blablabla[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.] System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +148 System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded() +10946558 System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +64 System.Web.UI.WebControls.HiddenField.LoadPostData(String postDataKey, NameValueCollection postCollection) +62 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +507 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11042743 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11042282 System.Web.UI.Page.ProcessRequest() +91 System.Web.UI.Page.ProcessRequest(HttpContext context) +240 Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest(HttpContext context) +175 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171</pre>\[/code\]What I've tried:
  • Disabling EnableViewstate on all controls (__VIEWSTATE hidden fields are still there)
  • Removing __VIEWSTATE fields on Page_Init (This causes ViewStateMac errors)
  • Setting viewstate encryption mode to 'never' (Doesn't make a difference)
  • Disabling and encryption and viewstateMac in config. (Get SessionState Error)
Can someone please give me some advice / suggestionsI hope I gave enough Info and also, please I want to understand this problem and not just do it in another way... The design is like this as a result of previous sharepoint issues.Thank you.
 
Back
Top