Skip to main content

Invalid Viewstate Problem

Recently I have been facing this problem of invalid viewstate. After googling a bit found some interesting concepts and solutions related to viewstate. So I thought let me just make a note of these references and have them handy.

This is from the Microsoft Support highlihgting some techniques that you can use to debug / troubleshoot this problem -
http://support.microsoft.com/?id=829743

This one is more interesting which highlights how you can get this problem while using Server.Transfer method, again from Microsoft Support -
http://support.microsoft.com/kb/316920/

This one here is related to machineKey set to auto generate in machine.config
http://forums.asp.net/p/1059371/1516632.aspx

This one here is related to third party web site (running on different framework version) posting into your web site.
http://blogs.msdn.com/tess/archive/2007/06/11/a-case-of-invalid-viewstate.aspx

Hope all your invalid viewstate problems get taken care of with this.

Here is the exception detail -

ExceptionSystem.Web.UI.ViewStateException: Invalid viewstate. Client IP: x.x.x.x Port: xxxx User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506) ViewState: /wE xxxxxxxxxxxxxxxxxxxx
Referer: https://xxxxxx/
Path: /xxx.aspx

Stack Traceat System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded() at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) at System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

And finally everything one needs to know about ViewState is here -
http://msdn.microsoft.com/en-us/library/ms972976.aspx

Comments

Popular posts from this blog

Notes on Castle MonoRail

  Sometime back I was doing a small POC on Castle MonoRail. So here are my quick notes on this. MonoRail is an MVC Framework from Castle inspired by ActionPack. MonoRail enforces separation of concerns with Controller handling application flow, models representing data and View taking care of the presentation logic. To work with MonoRail you need Castle Assemblies. It also utilizes nHibernate You can use Castle MonoRail Project Wizard or create the project manually. Project structure – Content Css Images Controllers HomeController.cs Models Views Home \ index.vm Layouts \ Default.vm ...

URL Rewriting

When I first ventured into this topic I thought this would be pretty straight forward but then being in software field I should have known better. Nothing is as simple as it sounds. So here we go URL re-writing in ASP.Net. What URL re-writing means is that you intercept an incoming web request in your web application and then redirect the web request to a different web resource in your web application. Now this is not done simply using Response.Redirect or Server.Redirect. There are many reasons why you would choose to do URL re-writing and the major ones could be - You want your urls to be search engine friendly. Your website has undergone restructuring or you expect the folders to be moved arround later. You want your urls to be user friendly (as in easier to remember). Any web request when it enters the ASP.Net engine an HTTPContext object is created and assigned to it and then it goes through a series of HTTPModules finally hitting a HTTPHandler. The HTTPContext object provides a m...

Workflow Foundation 4 - Part 3 - Data storage and management

This is my third post on WF4. First one was an introductory post on WF4 and in second one we focused on executing workflows. In the this post I am going to focus on the topic of data storage and management. Every business process or flow depends on data. When you think of data there are three elements to it as listed below - Variables - for storing data Arguments - for passing data Expressions - for manipulating data. Let us first look at the variables. Variables are storage locations for data. Variables are declared before using them just like in any other languages like C# or VB.Net. Variables are defined with a specific scope. When you create a variable in an activity the scope of the variable becomes that activity's scope. Variables can also have access modifiers like None, Mapped or ReadOnly. Let us look at an example where we will create two variables and assign a scope to them along with access modifiers. //Declare a sequence activitiy Sequence seqWf = new Sequence(); //de...