Errors: Failed to load viewstate. & Validation of viewstate MAC failed.

S

sck10

Hello,

I have applications that produce the following error when they have been
open to long without activity. Is there any way to force a re-load of the
page or go to another page if the page has expired instead of getting the
error?

Thanks,


Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during
the previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request.


Server Error in '/' Application.
Validation of viewstate MAC failed. If this application is hosted by a Web
Farm or cluster, ensure that <machineKey> configuration specifies the same
validationKey and validation algorithm. AutoGenerate cannot be used in a
cluster.
 
K

KJ

A few preliminary questions: are you hosted on a web farm; if so, do
you have enableViewStateMac set to false in your Web.Config, for
example:

<pages enableViewStateMac="false"/>
 
S

Steven Cheng[MSFT]

Hello Steve,

From your description, the problem occurs when the page has been idle for
long time. Does it occur when the page is display in short time and be
fresh? For long time idle page, I think the exception is likely due to the
viewstate MAC has been expired and the server runtime can not validate it.
ASP.NET will perform a simple digest on the viewstate and check it later
when page postback, however, this digest is not valid forever, after long
period, it could refresh it. I've also seen some one encountering such
problem when using page cached in google page cache.

For your another question:
================
Is there any way to force a re-load of the
page or go to another page if the page has expired instead of getting the
error?
================

Do you think use client-side script to set a timer and postback/reload the
page after a certain periold workable for you? e.g.

#the following page use script to reload the page after 20 secs
==================
....................
<script type="text/javascript">
function client_onload()
{
window.setTimeout("refresh_page()", 20000);
}

function refresh_page()
{
window.location.href = window.location.href;
}
</script>
</head>
<body onload="client_onload();">
<form id="form1" runat="server" >
<div>
..............
===============

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,834
Latest member
BuyCannaLabsCBD

Latest Threads

Top