Solved

Invalid Viewstate

Posted on 2009-07-03
4
413 Views
Last Modified: 2012-05-07
My application is .net 2.0.  I have around 40 sites running the same app for multiple customers.  I get intermittant invalid viewstate errors that affect stability of the app.  I have researched this, but not found a solution.

1. The app is running on my own server.
2. I use NLM, but only one server is active.  It is for backup purposes to redirect to a backup server.
3. I am on .Net 2.0
4. I have added a machine key to the web.config for all sites (below).  This didn't make a difference.
5. From my application log, I see the error (at least sometimes) happens on the initial post to a form.  For example, I click on a menu link to open a new form, and I get the error.
6. I don't have any anti-virus software running on the server.
7. The error happens too often to assume that is is a App Pool recycle error.

There is a lot written about this error, but I can't seem to find the issue.  Help!
<machineKey validationKey="1111111111111112CAD731F96F1ABC096D05090C9AD6623AB99C56ADB7E774045CC6AD2D86A24FD8BE8BA19E809E35ACA5BAD28B4762EC126471BA373CB28628"
                decryptionKey="30866BB7F1D1B392A17F675CD6425C83FB90351365D82AA5" 
                validation="SHA1" />
 
Some values were changed for this post

Open in new window

0
Comment
Question by:No1Coder
  • 2
4 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24937060
Sometimes there's only so much you can do. Once I remember having a similar problem and after hours of research I found out that when I did a forced redirect with NoStore header set, all went fine. Not a nice solution, but it at least took away the errors from the clients.

Later I found out that there was one control (a label in my case) that disrupted the process. Apparently the label state was remembered in the viewstate. By disabling the viewstate for a few specific controls I managed to stop the error.

Not sure if this approach is something for you, but it may be a workable solution if you do not want to lower your security to something that allows the passing of these viewstates. You can catch the error globally through either global.asax or registering a thread error handler.

-- Abel --
0
 
LVL 20

Expert Comment

by:informaniac
ID: 25012845
Have u used Client Callback anywhere in ur application?

Or are using javascript to call a server side event. say button click?
0
 

Accepted Solution

by:
No1Coder earned 0 total points
ID: 25013455
I worked with Microsoft on this.  Moving the page_load code to page_init helped.  Also, turning off viewstate on some grids helped.  I can;t say it is fixed, but the number of instances have been greatly reduced.
0
 
LVL 39

Expert Comment

by:abel
ID: 25016777
They haven't been able to pinpoint one particular problem or issue in your code that caused this erratic behavior? Must be quite disappointing, though glad to hear that you got it partially resolved.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question