1

I've been working on a handful of ASP.NET user controls which will be integrated into a Sitecore CMS instance. Development has been completed using some dummy aspx pages to host the controls and everything works fine locally and when the project is deployed onto a test server.

However, when we integrate the modules into Sitecore a few actions cause an 'Invalid Viewstate' exception - 'Invalid character in base64 string'. I have replicated this locally, i.e. on my dev system, by configuring IIS to look at the Sitecore project so this leads me to believe that it is not a server issue but obviously I can't be sure of that.

Using fiddler I can see that the POST request contains not one but two __VIEWSTATE fields, indeed __EVENTVALIDATION, __EVENTTARGET and __EVENTARGUMENT have two instances each in the request. The __VIEWSTATE values are identical and I can decode the content (hence I assume that the failure is due to the presence of two values, not an error in either one of them). The two __EVENTVALIDATION values are different but both are valid (i.e. they decode) and the other __EVENT fields are empty.

If I remove the UpdatePanels from the control then eveything works 'OK' - obviously there are no AJAX partial page updates now though which is not ideal. If I disable Jscript in my browser with the UpdatePanels back in the code, then again everything is 'OK'.

Can anyone shed some light on this or point me in the right direction - I'm out of ideas now and if I can't sort it I'll have to remove the UpdatePanels and see if we can live with the result, not ideal.

[Update 14-02-2012] I've been trawling the web but have not really found anyone with the same problem. I thought I'd struck gold with this post but again it made no difference to my problem. All indications are that AJAX on Sitecore should work fine but so I'm guessing that we must have a configuration problem. Problem is that I'm not a Sitecore developer and currently I don't have access to one (annual leave!)

DilbertDave
  • 3,406
  • 3
  • 33
  • 42
  • Please provide a code sample. Also, are you using the UCs as straight UCs or are they Sitecore sublayouts? – Mark Ursino Feb 13 '12 at 15:37
  • Providing a code sample may be an issue due to the content - I'm looking at creating a dummy control to see if I can reproduce it and then i can post that code up. The controls have been developed as if they were 'normal' usercontrols - I've made no special account of Sitecore at all. – DilbertDave Feb 13 '12 at 15:43
  • Are the UCs being used within Sitcore sublayouts? I.e., do you have a sublayout that may reference one or more of the custom UCs that are being problematic? – Mark Ursino Feb 13 '12 at 15:58
  • To be honest, I don't know! I'm no expert on Sitecore and am contracted to develop the user controls only. I'll tag on the Sitecore guys and see what they say. – DilbertDave Feb 13 '12 at 16:08
  • @MarkUrsino: Apparently the UCs are being used within sublayouts but they guys here can't see any issues with the configuration. I've posted the above into the Sitecore forum to see if Support can assist. Will post any feedback in here of course. – DilbertDave Feb 14 '12 at 11:18

1 Answers1

1

Two __VIEWSTATE fields sounds very much like you have two form elements in the page, possibly as the result of some jQuery or AJAX interactions.

This post sounds similar: "Invalid Character in Base-64 String" using ASP.NET and C#

Are you using ASP.NET AJAX? I'd review exactly what the JavaScript is doing to the DOM - it's likely inserting the extra form element.

Community
  • 1
  • 1
Matthew Skelton
  • 2,220
  • 21
  • 21
  • I was using ASP.NET AJAX but I couldn't see a duplicated `form` elements. I've moved on from that client now (I'm a freelancer) but I'll point them back to this answer to see if that sheds any light on the problem. – DilbertDave May 16 '12 at 07:12