How to fix ViewStateException Invalid ViewState?
Usually you don’t see Invalid ViewState exception unless you implement some kind of ASP.NET error logger in Global.asax.
Error usually states something like this:
Exception: System.Web.HttpException: The state information is invalid for this page and might be corrupted. System.Web.UI.ViewStateException: Invalid viewstate.
Those errors are usually generated by some automatic submission form engines. Comments and contact forms are mostly effected by this exception. The end user never sees those errors, so invalid viewstate errors don’t have any value for your error logger. Let’s bypass them:
if (ex is HttpException && ex.InnerException is ViewStateException)
{
_app.Response.Redirect(_app.Request.Url.AbsoluteUri)
return
}
See my error logger article for further details.