Answered by:
ViewState Error

Question
-
User-1868929400 posted
Hi All,
I have hosted one web site on internet.
But after testing it we come to know that after some ideal time if i try to surf my website it gives below error:
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. See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.
I went through this page but don't know where and how to to generate machine key.
Please Help me to solve this error.
Thanks,
Regards,
Jayesh(From India,Mumbai)
Tuesday, October 28, 2014 2:27 AM
Answers
-
User-484054684 posted
Hi Jayesh
Have you hosted your application in multiple servers (web farm)? If so, the key used for one machine will be invalid for other machine. So, we need to add machineKey that time.
There are multiple causes in fact.
There is a very good KB article here which explains each cause and the solution for it: http://support.microsoft.com/kb/2915218
Hope this helps.
Regards
Siva- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 28, 2014 7:27 AM -
User571301025 posted
Your application is hosted in a web farm environment that is multi server environment. In each server, the ASP.Net runtime exists. But the machine key is different between them.
Your first request goes to Server A then the second request handled by Server B. Because of machine key difference, Server B unable to understand it. That's why these kind of error occured.
http://go.microsoft.com/fwlink/?LinkID=314055
The above link provides enough information. Also it states the other reasons behind this error.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 28, 2014 7:34 AM -
User-484054684 posted
Hi Jayesh,
I hope you hosted your application in some hosting provider environment? If so, hosting provider administrator or support group are the right contact to check with regarding the above activity.
However, if you want to goahead with disable validation (though not recommended if u r using viewstate) or, if you want to generate machineKey and paste in web.config, following discussion should help:
i.e., adding this in <system.web> section of web.config:
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />
If you generate the machinekey, that should be put in web config similar to below:
<machinekey validation="SHA1" validationkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1B2C3D4E5" decryption="Auto" decryptionkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1" />
Reference: http://www.codeproject.com/Questions/321511/Validation-of-viewstate-MAC-failed
Regards
Siva
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, October 29, 2014 9:30 AM -
User-484054684 posted
Hi Jayesh,
I've found few more details about this issue and posted in this question: http://forums.asp.net/t/2016565.aspx?System+Web+UI+ViewStateException+Invalid+viewstate+Client+IP+127+0+0+1+Port+xxx+Referer+xxx
Excerpt:
It could also be due to the page being rendered slowly on a slow network. i.e., if the page is not rendered completely (especially the hidden fields of viewstate), and if the user tries to click on some button in the meantime, then there are chances of getting this error. There are workarounds to disable and enable the form once all the controls are loaded, etc.
There is a good article explaining this http://blogs.msdn.com/b/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
App pool recycles also may cause this issue,
Also check if there is any virus scanner being run during that time: Reference: http://support.microsoft.com/kb/555353There is another good trouble shooting reference from Microsoft: http://support.microsoft.com/kb/829743
I hope, you would get the resolution after going through these notes.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, October 31, 2014 10:22 AM
All replies
-
User-484054684 posted
Hi Jayesh
Have you hosted your application in multiple servers (web farm)? If so, the key used for one machine will be invalid for other machine. So, we need to add machineKey that time.
There are multiple causes in fact.
There is a very good KB article here which explains each cause and the solution for it: http://support.microsoft.com/kb/2915218
Hope this helps.
Regards
Siva- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 28, 2014 7:27 AM -
User571301025 posted
Your application is hosted in a web farm environment that is multi server environment. In each server, the ASP.Net runtime exists. But the machine key is different between them.
Your first request goes to Server A then the second request handled by Server B. Because of machine key difference, Server B unable to understand it. That's why these kind of error occured.
http://go.microsoft.com/fwlink/?LinkID=314055
The above link provides enough information. Also it states the other reasons behind this error.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, October 28, 2014 7:34 AM -
User-1868929400 posted
Hi francissvk ,Siva Krishna Macha, Thanks to answering to my post.
I am using iis and visual studio web server.
But on internet how to make one of the server to stop and to make only one server for use.
Please tell me how to stop one server among this two servers.
Please Help.
Regards,
Jayesh(From India,Mumbai)
Wednesday, October 29, 2014 1:47 AM -
User-484054684 posted
Hi Jayesh,
I hope you hosted your application in some hosting provider environment? If so, hosting provider administrator or support group are the right contact to check with regarding the above activity.
However, if you want to goahead with disable validation (though not recommended if u r using viewstate) or, if you want to generate machineKey and paste in web.config, following discussion should help:
i.e., adding this in <system.web> section of web.config:
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />
If you generate the machinekey, that should be put in web config similar to below:
<machinekey validation="SHA1" validationkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1B2C3D4E5" decryption="Auto" decryptionkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1" />
Reference: http://www.codeproject.com/Questions/321511/Validation-of-viewstate-MAC-failed
Regards
Siva
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, October 29, 2014 9:30 AM -
User-484054684 posted
Hi Jayesh,
I've found few more details about this issue and posted in this question: http://forums.asp.net/t/2016565.aspx?System+Web+UI+ViewStateException+Invalid+viewstate+Client+IP+127+0+0+1+Port+xxx+Referer+xxx
Excerpt:
It could also be due to the page being rendered slowly on a slow network. i.e., if the page is not rendered completely (especially the hidden fields of viewstate), and if the user tries to click on some button in the meantime, then there are chances of getting this error. There are workarounds to disable and enable the form once all the controls are loaded, etc.
There is a good article explaining this http://blogs.msdn.com/b/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
App pool recycles also may cause this issue,
Also check if there is any virus scanner being run during that time: Reference: http://support.microsoft.com/kb/555353There is another good trouble shooting reference from Microsoft: http://support.microsoft.com/kb/829743
I hope, you would get the resolution after going through these notes.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, October 31, 2014 10:22 AM -
User-1868929400 posted
Hi Siva Krishna,
Thanks to reply to my post.
I found information regarding machine.config file where i need to set certain data.
I found it in below path:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
But i dont know where to place it online in web site folder.
Please Help !
Regards,
Jayesh(From India,Mumbai)Saturday, November 1, 2014 1:37 AM -
User-1868929400 posted
Hi All,
I got the solution.
add below line in web.config page.
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" >
I am not getting viewstate mac error after adding this to my web.config.
Regards,
Jayesh(From India,Mumbai)
Saturday, November 1, 2014 3:25 AM