Sunday, September 20, 2009

Invalid viewstate - Unable to validate data Exception

I was receiving following error message constantly in my error log.


Invalid viewstate. Client IP: 127.0.0.1 Port: User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; FDM; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30729; 6696076703) ViewState: /wEPDwULLTE0NTg5OTI1MzJkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBRZjdGwwMCRDQyRjaGtSZW1lbWJlck1lBRZjdGwwMCRDQyRjaGtUZXJtc09mVXNl4IYD7Rs56CiQOVAEKcORk75X2xw= Referer: http://localhost:56095/HotLinks.aspx Path: /HotLinks.aspx

System.Web.HttpException: Unable to validate data. at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)


Cause of this error:
My web application has multiple forms, and from each form if user wants to post feedback and if he is anonymous user, he is redirected to login form.

To improve performance of web application i was using Server.Transfer to redirect anonymous user to login form.

As Server.Transfer don't change the url string, so even if user is on login form, it will still displays last url in browser, everything would be fine, until page is postback, if you do so than it would generate invalid viewstate error. As whenever you are doing page postback it needs to have correct url in order to post back to that page. But in this scenario, even though i am doing page postback on login form, its still assumes last page and so it end's up in above error message.

Work Around/Solution/Temporary Fix for Problem:
I couldn't able to find any good solution, but you can change your Server.Transfer call to Response.Redirect to fix the problem and move ahead.

I would update this post if i found any better solution to deal with this situation.

Wednesday, September 09, 2009

Patterns and practices Tutorial for SharePoint Applications

Patterns and practices Tutorial for SharePoint Applications

If it is not possible to read whole Patterns and Practise Tutorial, than you must read "Server Development" topic atleast which explains some of best practises to develop Sharepoint Applications which you can immediately apply in day to day development.

Best Practise and Considerations while developing Sharepoint Application

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape