I faced a weird issue where I was not able to add any web parts to any page in the site. What weird is that Chrome works fine. It happens only in IE (all versions) and FireFox. On inspecting the bug I got an error when the page tries to get the web parts data back from the server asynchronously (you can view it in the console window/network traffic)
The error looked in FF console window some thing like this:
And the detailed Exception message was some thing like this:
[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.Util.DeserializeWithAssert(IStateFormatter formatter,
String serializedState) +59
System.Web.UI.HiddenFieldPageStatePersister.Load() +124
[ViewStateException: Invalid viewstate.
...
...
[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.HiddenFieldPageStatePersister.Load() +10989814
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +11074728
System.Web.UI.Page.LoadAllState() +46
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsy
ncPoint, Boolean includeStagesAfterAsyncPoint) +11070247
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPo
int, Boolean includeStagesAfterAsyncPoint) +11069786
System.Web.UI.Page.ProcessRequest() +91
System.Web.UI.Page.ProcessRequest(HttpContext context) +240
ASP.LEFTRIGHTWIDEPAGELAYOUT_ASPX__745581150.ProcessRequest(HttpContext
context) +9
Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest
(HttpContext context) +175
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecu
tionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean
& completedSynchronously)
Did some research for almost a day and it turned out to be an issue that I
introduced when fixing an issue with Chrome browser which did not load
the SP.js file for all the clients. I inserted the below java script in
all the page layouts which triggered twice in IE and FF which caused the
issue.
The java script which introduced the bug is
if (typeof (_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();
the js function _spBodyOnLoadWrapper() got called twice and made the web parts panel to stop working.
I got this above javascript to fix some bugs in Chrome browser from the below site
http://developer.mintrus.com/2012/08/sharepoint-2010-improving-chrome-support/
But I made a mistake of just copying the the code to call just the function regardless of what browser it is. It made my day worse.
Be
cautious to not to mess with all the JavaScript function of SharePoint.
If you do make sure twice you are doing the right thing. Track any java
script errors occur in any page before moving forward.
This I learnt the hard way. I still enjoy coding.
Happy Coding.
Senthil S