Validation of viewstate MAC failed

LakshmiLakshmi Posts: 15
edited February 28, 2007 4:14AM in ANTS Load
Hi,

We are getting this error when we create ANTS Load script. We have now changed the web.config to add the following line:
<pages enableViewStateMac="false" enableEventValidation="false"
viewStateEncryptionMode="Never" maxPageStateFieldLength="200" />

Though the error does not occur, the database does not get updated with records.......We have also hard coded the view state, but the main click event or POst does not happen....the code does not get called for the final save event.

Could anyone please help on that?

Regards,
Lakshmi
Lakshmi

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi,

    The Viewstate is the most common beastie that happens when trying to load test an ASP .Net application. Just search this forum to see the various and vicious ways that this happens. More than likely your fix is not helping because viewstate is dynamic and hard-coding it will only lead to different errors.

    There seems to be a basic problem with viewstate in your load test. The message about the viewstate MAC, which relates to encryption, is probably a red herring. The real problem is that the viewstate you're sending back to the server is just plain wrong.

    The most common cause of this relates to websites that use frames or iframes. This causes viewstate to be sent back to the server for the wrong page, because ANTS Load only has one slot for viewstate data, it is not maintained per-page. Therefore, if your web browser session recorded a request for page a, then b, then c, and your form posts to page b, the viewstate for page c gets posted back to page b.

    So what you would need to do is edit your script so that the GET request for page b happens right before the POST to page b. You can try the ANTS Script tester from http://labs.red-gate.com to try to figure out exactly where the breakdown is occurring.
  • Hi Brian,

    We have already put a GET before every post to get the correct view state....

    Also, we have used Fiddler, and the View state from there for each post and hard coded the same and have tried sending the post but does not seem to work.

    We have a problem where a particular save button event does not get fired, because of which we are unable to save to the database.....any insights into this would be helpful.

    Thanks and Regards,
    Lakshmi
    Lakshmi
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hard-coding the viewstate is a very bad idea. Did the script tester reveal anything?
  • Hi Brian,

    We did use the script tester, but we got nothing from there.....

    We do not get the error of the View state failed....but no records get inserted into the database.....

    Note: At times just putting the GET does not help to get the viewstate.

    Regards,
    Lakshmi
    Lakshmi
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    This looks like one of the typical application-specific errors to do with ANTS Load. I can't help really, except to suggest using Me.LogToFile on your sessions' scripts and seeing if the pages returned in the response content are correct. In a few cases, the scripts work once, but fail on subsequent attempts because of data that is meant to be dynamic being static in the ANTS Load script, or a script not logging the user out at the end, the result is usually a bunch of 'you must log in' pages in the second run.
Sign In or Register to comment.