Invalid ViewState Error – Validation of ViewState MAC failed


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.

 

In above exception viewstate is not getting validated/authenticated by the server. This happens when encryption key used for encrypting viewstate does not match on different servers in the web farm.
When we deploy an asp.net web application into a web farm environment, each web servers machine.config or web.config must specify the same key used for encrypting the view state. As view state is encrypted for security reasons and each machine.config on each web server will have a different key so they must all be the same. If they are different then viewstate created by one server will not be understood by other server and hence the above error.
Instead of editing machine.config file which may affect other applications running on the same server.
Best way is to add a machineKey element into each of the web server’s web.config and define the same keys and algorithm.
The machineKey goes under the System.web node. for e.g.
<machineKey validation=”SHA1″ validationKey=”A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4 E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1B2C3D4E5″
decryption=”Auto” decryptionKey=”A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1″ />
for machinekey setting parameters you can refer http://msdn.microsoft.com/en-us/library/w8h3skw9.aspx

There are few more reasons why this error may occure, Like while trouble shooting –

1. Please check Application Pool Recycling settings in the IIS, IIS keeps on recycling the application pool to maintain the applications health. During this recycling process requests from the client may get into invalid viewstate situation.The fix in this case is to adjust the settings on the application pools so that recycling is less likely to occur at peak periods
2. Any Antivirus software or firewall settings may diesect the viewstate, creating difficulty for sever to validate the viewstate.
3. Improper Form Posts- Viewstate can only be posted back to the same page.  Attempting to post an aspx form to another page will fail with a viewstate invalid exception. This behavior is by design and obvious.
Some developers choose to disable the encryption of viewstate(ViewStateEncryptionMode =ViewStateEncryptionMode.Never) which is bad design, encryption is required so that no one should tamper the view state.
Advertisement

21 Responses to “Invalid ViewState Error – Validation of ViewState MAC failed”

  1. Anonymous Says:

    I like to disseminate knowledge that I’ve accrued with the yr to assist improve team performance.

  2. flyers murah Says:

    I always spent my half an hour to read this web site’s posts all the time along with a mug of coffee.

  3. Anonymous Says:

    Good day! I just want to give a huge thumbs up for the nice information
    you have here on this post. I will be coming again
    to your blog for extra soon.

  4. health Says:

    Hey I know this is off topic but I was wondering if you knew of
    any widgets I could add to my blog that automatically tweet my newest twitter updates.

    I’ve been looking for a plug-in like this for quite some time and was hoping
    maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading
    your blog and I look forward to your new updates.

  5. http://www.Cibuburnews.com/ Says:

    Thank you for any other informative site. Where else may I get that kind of
    info written in such a perfect method? I’ve a undertaking that I’m simply
    now working on, and I have been on the glance out for such information.

  6. www.podpora.cz Says:

    Hi there, I enjoy reading through your post. I wanted to write a little comment to support you.

  7. http://expotobang.com/xe/?document_srl=285553 Says:

    Having read this I thought it was rather informative.

    I appreciate you spending some time and energy to put
    this content together. I once again find myself spending a significant amount of time both reading and posting
    comments. But so what, it was still worthwhile!

  8. katering kielce Says:

    Hello every one, here every one is sharing such experience, therefore it’s nice to read this webpage, and I used to pay a quick visit this blog daily.

  9. buy liposlim Says:

    I like your site the idea seemjs wonderful I really hope you keeep bringing up-to-date!

  10. fun mobile games Says:

    Wow, superb blog format! How long have you been running a blog for?
    you made blogging glance easy. The overall glance of your web site is fantastic, as
    smartly as the content material!

  11. standard website Says:

    This is very attention-grabbing, You are an excessively skilled blogger.
    I’ve joined your feed and look ahead to looking
    for extra of your fantastic post. Additionally, I’ve shared your
    website in my social networks

  12. judi bola online menggunakan bank bri Says:

    Thanks for some other wonderful article. Where else may just anyone get that kind of info in such an ideal method of writing?

    I’ve a presentation subsequent week, and I am
    at the search for such information.

  13. Alisia Says:

    whoah this weblog is great i like studying your posts.
    Stay up the great work! You realize, a lot of individuals are
    hunting round for this info, you could aid them
    greatly.

  14. download video from blog Says:

    Wow, that’s what I was seeking for, what a material!

    existing here at this web site, thanks admin of
    this site.

  15. youtube.com Says:

    Simply wish to say your article is as astounding.
    The clarity in your post is simply nice and i can assume you
    are an expert on this subject. Well with your permission let me to grab your RSS feed to keep
    up to date with forthcoming post. Thanks a million and please continue
    the rewarding work.

  16. manufacturer web design Says:

    Thank you for sharing your thoughts. I really appreciate your efforts and I will be
    waiting for your further write ups thank you once again.

  17. Kristal Says:

    great issues altogether, you simply received a new reader.
    What would you recommend in regards to your submit
    that you just made some days ago? Any certain?

  18. live broadcasting sites Says:

    Hi there, I want to subscribe for this web site to get hottest updates, so where can i do it please help.

  19. Louann Says:

    My family members always say that I am killing my time here at web, but I know I am
    getting knowledge daily by reading thes good posts.

  20. Loan Helps Says:

    I seriously love you site.. Great colors & theme. Did you make this
    website yourself? Please reply back as I’m wanting to create my
    own blog and want to find out where you got this from or what the theme is called.
    Thanks!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: