viewstate error

Discussion in 'General Web Coding' started by Typ0, Mar 21, 2007.

  1. Typ0

    Typ0 Perch

    Has anyone dealt with the below error? what key did you use to solve it in this server farm?

    Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
  2. DaveMBush

    DaveMBush Guppy

    Yes, I've dealt with it.

    Are you running on a web farm?
  3. Typ0

    Typ0 Perch

    I am not sure actually. I'm a jodohost reseller using hsphere. So if I'm on a web farm is one of the questions I'm trying to get answered here. And then, of course, how to make this issue go away as it's annoying. thank you for the reply.
  4. DaveMBush

    DaveMBush Guppy

    If you are running here, you aren't running on a web farm.

    I need to know more about the application you are running.

    Are you dynamically generating controls or user controls? You generally get this error on a stand alone server when the controls you used to create a page are not the same controls that got loaded on the postback.

    Does this same app work when you run it on your local computer?
  5. Typ0

    Typ0 Perch

    it seems to happen to me when i go to a page and then walk away from the computer...then I come back and try to log in. It's like my logon control is being rendered with viewstate...and then the application is generating a new viewstate when you try and log in after it sits for a while.

    I do have a lot of custom user controls in use. they use datagrids and datareaders to display data amongst other things.
  6. DaveMBush

    DaveMBush Guppy

    It sounds like the ViewState hash is set to "auto" in the server's machine.config file. If this is true then you'd get a new key everytime the app pool recycles.

    Fortunately, you should be able to override those values in web.config

    Go here and create your machineKey element ASP.NET Resources - Online tool to create keys for view state validation and encryption and then place it in your web.config file inside the <system.web> element that is nested insite the top level element named <configuration>

    If I'm right about the problem, this should fix your issue.
  7. Typ0

    Typ0 Perch

    Thank you for the response. It seems to be working.
  8. Typ0

    Typ0 Perch

    can you articulate the security concerns with this solution?
  9. DaveMBush

    DaveMBush Guppy

    What security concerns?

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services