Friday, August 26, 2005

Web Farms and View State Problem

When deploying a web application from one server to another you may come acroos this error... System.Web.HttpException

Encryption of data storage in viewstate will be based on server's MAC Address..We can avoid this error by setting enableViewStateMac to false.

Using enableViewStateMac requires that successive requests be forwarded to the same server (i.e. server affinity). This feature is used to help prevent tampering of a page's view state; however, it does so based on an auto-generated validation key on the current server. From this key, a message authentication code (MAC) is generated and sent in the ViewState back to the browser. The problem is that if a POST back is performed and goes to a different server, you will get a nice little error message saying “Corrupt View State“.

To fix this, you can either set enableViewStateMac to false in the element or specify a common value for the validationKey attribute in the element across all servers (in the farm).

By the way, documentation says that this is OFF by default. That is incorrect! Go check machine.config!

Visit Page Section for more details.

And also MSDN Mag Cutting Edge for more details.

0 பின்னூட்டங்கள்: