0

We have an asp.net webpage that uses viewstate. During a lengthy operation (that takes more than 12 minutes) there happens a view state related error as listed below.

The controls from the page gets vanished. 
It simply writes on the screens as 
"input type=”hidden” name= ”_VIEWSTATE” id= ”_VIEWSTATE” value =’/wEPDw…” 

When the viewstate is avoided, this is working fine. One more observation is that when we connect to the VPN and run it as intranet, it is working fine even with viewstate.

I have read from Does viewstate expire? that “Even though ViewState won't expire, it can become invalid if a different autogenerated key is used to decrypt ViewState, such as after an IIS Reset, redeploying an application, or hitting a different server in a web farm.”

• We have a load balancer (with two web servers)

• We are not restarting IIS

• We are not redeploying the application during the test

So, what are the possible reasons for this error? How can we resolve it without removing viewstate?

Can this be related to Proxy server truncating View State ? How to confirm that whether it is a problem caused by proxy or firewall?

Thanks

Lijo

Community
  • 1
  • 1
LCJ
  • 22,196
  • 67
  • 260
  • 418
  • What is the error? You say "as listed below" but that line just shows some very short viewstart - it doesn't show an error? – Stuart Jul 17 '11 at 10:13
  • Can you do "view source" on that error page? Is there anything else there? – Stuart Jul 17 '11 at 10:23
  • I think the error does not relates to the viewstate. You have wrong logic on server side that preserve some data in viewstate. Try to Disable the Viewstate sectionally(From whole page to certain controls) – chapluck Jul 17 '11 at 10:28
  • Does both your webservers have the same machine key configured? – sisve Jul 17 '11 at 10:33
  • @ Simon: Yes, I have put the machine key inside web.config and used same web.config in both the web servers. @ Stuart: The viewsource is like follows:
    – LCJ Jul 17 '11 at 11:09

1 Answers1

4

We have a load balancer (with two web servers)

So ensure that you have specified the same machine keys on both your web servers instead of the default autogenerated value. You could also specify this value in the web.config of your application:

<machineKey 
    validationKey="21F090935F6..."           
    decryptionKey="ABAA84D7EC4..."
    validation="SHA1"
    decryption="AES"
/>

This will ensure that no matter which web server encrypted the viewstate the other will be able to decrypt it. You could also use an online tool for generating machine keys.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I put the machine key inside web.config and used same web.config in both the web servers. But I am getting the same error. – LCJ Jul 17 '11 at 09:38
  • Also, why it does not happen when I connect through VPN? – LCJ Jul 17 '11 at 09:46