Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
I have a page with UpdatePanel and ASP:Timer, that refreshs the UpdatePanel every minute.
 
It was noticed that after new release after the first refresh any postback causes
"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
 
I've searched Google and found that this error is quite common. Below there are just a few suggestions:
 
I do not consider viewStateEncryptionMode ="Never" enableViewStateMac="false", because it is asecurity risk.
 
Set maxPageStateFieldLength (from http://forums.asp.net/t/955145.aspx?PageIndex=9) MSDN: When the MaxPageStateFieldLength property is set to a positive number, the view state sent to the client browser is broken into multiple hidden fields, and each field's value is less than the size specified in the MaxPageStateFieldLength property. ViewState Chunking in ASP.NET 2.0 (maxPageStateFieldLength)
 
blog Validation of viewstate MAC failed error:
It appears when using built-in databound controls such as GridView, DetailsView or FormView which utilize "DataKeyNames".
3. It appears if you have a large page which loads slowly for any reason.
Workarounds includes
* sample code to override the Render Event of the page to place the hidden fields for Encrypted Viewstate and Event validation on the top of the form.
* mark the form as disabled and then enable it in script once the load is complete.
 
Server Side Viewstate article in .Net 1.1 -should be 2.0 version
 
Another post suggests to add
PostBackUrl="~/samepage.aspx"
 to your Button which triggers the Postback Event:

 

Workaround from MS connect:
<meta http-equiv="Page-Enter" content="RevealTrans(Duration=0,Transition=0)" />
Essentially, including this tag in the header of your page disables the use of the page until it has completely downloaded to the browser.
 
Links related to debugging/viewing  ViewState
 
Posted on Wednesday, March 19, 2008 12:09 AM ASP.NET , Testing/Debugging/Logging | Back to top


Comments on this post: Validation of viewstate MAC failed when using asp.timer to trigger UpdatePanel

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net