Solution for 'Validation of viewstate MAC failed'

by Anand Prabhu 3. April 2010 04:51

Server Error in '/' Application.

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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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.

-------------------------------------------------------------------------------------------------

Do you get above error in your website?

This means that Content Services Switch or Load Balancer is established in your application servers and thus causing this error.

The problem now is that most of the web applications require to maintain the client connection to same server till the client ends the connection. CSS by default connects the client request to which ever the server is free at that moment. If the first request of the client is handled by SERVER1(10.2.2.1), CSS may direct the same client request to SERVER2(10.2.2.2) if SERVER2 is comparatively free than SERVER1. Even if the same version and patches of web application is maintained at SERVER1 and SERVER2, Machine Key and session information will not be available on both the servers. So now, what you need to do is setting up of  'stickiness' in CSS content rule.

Before trying to resolve it, I explain you some technical terms related to this bug.

  • Viewstate: Explained very well here http://www.dotnetjohn.com/articles.aspx?articleid=71.
  • MAC (Viewstate MAC): ASP.NET runs a message authentication check(MAC) on the page's viewstate when the page is posted back from the client. This is to ensure that the same client sends the requests without data tampering in between transmission. Some peoples suggest to disable this check by setting enableEventValidation="false" (see bulletin 1 below), but please be aware of the consequences of security risk. Disabling this check skips the validation of postback and the attacker could spoof the postback data and corrupt your application or servers.

  • Web Farm: Two or more server balancing the traffic of a web application. In a Web Farm, a front-end load balancer will handle the client requests and distribute it between the back end application servers.
  • Content Services Switch (CSS):  CSS receives the client request for content and directs to a specific server, say for example, if you have setup CSS to balance the load between two servers, then it would send the client request to the servers which are free at that moment. To assist you in understanding see the setup diagram below,

Other suggested solutions that I do not prefer to do:

 1.             Try adding this string in <system.web> section of your web.config file :
                <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />
                for fix "Validation of viewstate MAC failed" error.

Even your issue is resolved by adding this line, it is like removing the speakers from 'Fire Alarm System'. 


2.              Force every server in your farm to use the same key; generate a hex encoded 64-bit or 128-bit <machineKey> and put that in each server's machine.config.

<machineKey     validationKey='123123GDGAGASGAGDGGAGDAGAG712879812701NVKAHDA9817913134FF01F3FADFSA9'

decryptionKey='190283091UJHFA701820938JFKAJF8' validation='SHA1'/>

 

You can generate a key from http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx

This solution is atleast better than the above one but again setting up of static machinekey is a security loop hole.


Proper Solution:

Include 'Stickiness' in CSS configuration

Stickiness will tell the CSS to maintain an association between client and same server connection (SERVER1 or SERVER2) till the connection ends.

 content rule-1
    protocol tcp
    vip address 172.20.20.20
    port 80
    add service webserver1
    add service webserver2
    advanced-balance sticky-srcip
    active

CISCO Advanced Configuration Guide of Sticky

Comments

6/12/2010 6:44:38 AM #

$$$ for you


This is my second time i visit here.

I discovered so many fascinating stuff in your pages especially it's discussion.

From the loads of comments on your articles, I assume I am not the only one having all the enjoyment here!

Keep up the good work. Thanks a lot !!

Have a Nice  day !!

=================================
$ 61,000 in Two Days . It's No Accident.
http://root.50webs.com/

$$$ for you United States

6/13/2010 3:04:54 PM #

cheap farmville shirts

FarmVille is a great place to go to escape the rigors of daily life. You can get back to  mother natureand enjoy the peace and tranquility that comes from working on the land. However, not everything in FarmVille is an escape from the ordinary. You still need cash for just about everything you do. You have to purchase the seeds to plant, and you'll even have to pay a small sum for each plot of land you plow.

cheap farmville shirts United States

6/15/2010 2:26:30 PM #

Gutrerrez@yahoo.co.uk

I disagree, I think you arguement is loose at best. Your going to have to do a lot more persauding to convince me.

Gutrerrez@yahoo.co.uk United Kingdom

6/16/2010 1:35:33 PM #

free online chat

Dear admin, thnxx for sharing this article! I found it awesome. Best regards, Brad R.!

free online chat United States

6/17/2010 1:34:28 AM #

Cheyenne Kathleen

Hey very good blog!!!! Wow... Gorgeous .. Amazing .. I’ll bookmark your weblog and take the feeds also...

Cheyenne Kathleen United States

6/17/2010 7:50:50 PM #

Smoking and Pregnancy

Hi Pretty good post. I just digg your site and wanted to say that I have really enjoyed reading your posts.

Smoking and Pregnancy United States

6/20/2010 8:08:29 AM #

abercrombie

Website very attractive. Congratulations!

abercrombie United States

6/25/2010 4:04:42 AM #

how to jump higher in basketball

jump higher uk speed and plyometrics.

how to jump higher in basketball United States

6/26/2010 10:41:18 PM #

bicycle

Bicycles is something I enjoy. It is possible that you know about the "Spanish Bicycle Tour" (vuelta ciclista to Spain). I saw it a couple of times and it is something I will always remember.

bicycle United States

6/27/2010 6:49:23 AM #

una car hire

I just wrote a truly long reply to this blog and it did not post. so so aggravating. I feel like knocking my head against the screen! ok, will attempt one more time..

una car hire United States

6/27/2010 7:55:50 AM #

free energy generator

free energy device concept of dipolar gravity

free energy generator United States

6/27/2010 8:44:29 AM #

laptop cheap review

great post. It's really helpful and I will bookmark this page. thanks

laptop cheap review Algeria

6/27/2010 3:04:51 PM #

Free No Download Slots

I enjoyed reading this blog. Will you be posting new comments?

Free No Download Slots United States

6/27/2010 3:10:26 PM #

Free No Download Slots

I enjoyed reading this blog. Will you be posting new comments?

Free No Download Slots United States

6/27/2010 8:13:59 PM #

Free Slots

When will you provide an update?  I would like to stay informed.  Thanks.

Free Slots United States

6/28/2010 6:17:08 AM #

Sybil Bushong

I want to send fast hi and want to say appriciate for this good I digg and searching through the web for some kind of enlightenedpost. like this, or at least a website. That coveredwhat i want to
Best Regards.

Sybil Bushong United States

6/28/2010 7:08:24 AM #

how to get abs fast

Although this guide is to the abdominal muscle train class of how to build abdominal muscles fast, do not ever take too lightly the other one reasons about personal training, certainly cardio workout perform along with eating habits. You could possibly realize on your process to build stomach muscles extremely fast you're not even looking at end result you expect, and additionally which might be considering that you should do numerous jogging to boot. In actual fact, formidable tummy within loose and flabby belly will cause you to be glimpse fat! Should that's ever previously materialized for you, doing some running provides your whole working hard maximum round in addition to tell you the exquisite stomach.

how to get abs fast United States

6/28/2010 7:38:25 AM #

Tinnitus Remedies

Awesome blog post, a great deal of valuable knowledge.

Tinnitus Remedies United States

6/28/2010 5:35:47 PM #

Tinnitus Remedies

Very interesting blog post.  Your current web-site is rather quickly starting to be certainly one of my top features.

Tinnitus Remedies United States

6/28/2010 6:40:31 PM #

iPod Repair

I found your blog via Google and found it indoctrinating and somewhat entertaining. Will you be updating it soon?

iPod Repair United States

6/29/2010 9:45:58 AM #

Leroy Weadon

There are many subject standards that I want to tell you here:   1. Critical topic   2. Hot topic that consists of several positive and negative effects   3. Main results after this topic end   4. Must create solving-problem side and technical effects   5. Create quick summarize that give reader a time for making future research. Thanks for giving me opportunities in commenting your site, especially if you want to give summary point for that. Nice time to see you.

Leroy Weadon United States

6/29/2010 8:03:28 PM #

Proven Penis Enlargement

Hey, at any time you can shoot me an e-mail. I hear that BE is producing some giant changes to their operation and as a fellow BE blogmaster I was curious to know should seriously you have heard anything about it.

Proven Penis Enlargement Syria

6/29/2010 11:05:11 PM #

sennheiser australia

Provocative thoughts here. Are you optimistic this is the exact way to look at it though? My own personal experience is that everyone should pretty much live and let live because what one person thinks just -- another person simply doesn't. Individuals are going to do what they want to do. In the end, they always do. The best we can hope for is to distinguish a few things here and there that hopefully, allows them to make just a little better informed decision. Otherwise, great post. You're definitely making me think! --Jeremiah

sennheiser australia United States

6/30/2010 6:07:08 PM #

PhotogLady

I'm excited to be finally posting online after all these years. There really is no mystery about it, is there? I just dropped by your blog and had to write. I'm a recent college grad, journalism major if you must know, and I love photography. I've got my site up but it's nothing to brag about yet. None of my stuff's been posted. Soon as I figure out how to do that, I'll spend the afternoon posting my best shots. anyways just thought I'd drop a line. I hope to return with more substantial stuff, stuff you can actually use. SPG

PhotogLady United States

6/30/2010 9:17:12 PM #

Chantay Meter

Hey very good blog!!!! Wow... Gorgeous .. Amazing .. I’ll bookmark your weblog and take the feeds also...

Chantay Meter United States

6/30/2010 11:26:05 PM #

Barack Obama Air Force One

It was very enjoyable to search this topic today and I stumbled onto this site. Seems to be an excellent match for me. Good creative approach to this, you have confirmed my deepest appreciation.

Barack Obama Air Force One United States

7/1/2010 8:31:46 AM #

Sarasota Condos

Nice writing. You are on my RSS reader now so I can read more later.

Sarasota Condos United States

7/1/2010 8:56:52 AM #

Car Hire

Love the template of this blog, simple yet effective. Its difficult to discover the right balance occasionally but this site loads quick and looks very good

Car Hire United States

7/1/2010 10:40:57 AM #

ghosts caught on tape

After searching Ask I found your site about Solution for 'Validation of viewstate MAC failed' . I think both are good and I will be coming back to you and them in the future. Thanks

ghosts caught on tape United States

7/2/2010 7:11:19 AM #

AIR JORDAN PRO CLASSIC

Thank you for sharing your thoughts. This really helps me in so many ways – It helps to see the human side of your blog and it really helps to know that ordinary people really can do this blogging thing and make extraordinary differences in the lives of others.

AIR JORDAN PRO CLASSIC United States

7/2/2010 8:41:32 AM #

Graham Ellerby

I found this post while surfing the net some random stuff. Thanks for sharing will be sure to follow this blog regularly and will email this post to my friends.

Graham Ellerby United States

7/2/2010 6:24:39 PM #

Stormy Allday

Cool piece, thanks. Can you expand on the first point in additional detail please?

Stormy Allday United States

7/2/2010 7:21:08 PM #

Sven Andersson

Hi nice blog You got there. I am from Norway and I found Your blog on Bing. Keep wrighting and I will check it out again.

Sven Andersson United States

7/3/2010 4:16:18 AM #

Hire a Car

nicely written post, makes a refreshing change from the amount of drivel I read every day. well researched and educational

Hire a Car United States

7/3/2010 6:09:13 AM #

Aurea Shiffer

I was searching for information about this on Bing and found your item. I found it to be very useful. Thanks

Aurea Shiffer United States

7/3/2010 12:34:12 PM #

registry fix free

It now runs just like the day it was new."

registry fix free United States

Month List

RecentComments

Comment RSS