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

5
  • What is the error? You say "as listed below" but that line just shows some very short viewstart - it doesn't show an error? Commented Jul 17, 2011 at 10:13
  • Can you do "view source" on that error page? Is there anything else there? Commented Jul 17, 2011 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) Commented Jul 17, 2011 at 10:28
  • Does both your webservers have the same machine key configured? Commented Jul 17, 2011 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: <div> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value= Commented Jul 17, 2011 at 11:09

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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. <system.web> <machineKey validationKey="C7..." decryptionKey="A9..." validation="SHA1" decryption="AES" />
Also, why it does not happen when I connect through VPN?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.