I am developing a website in AS.net and its worked well on web server also. But , this application causes the following error while didn.t browse any functionality in browser after half hour.
Validation of Viewstate MAC failed. If this application is hosted by a web farm or cluster, ensure that <machinekey> configuaration specifies the same validation kety and validation algorithm. Autogenerated cannot be used in a cluster.
Validation of Viewstate MAC failed. If this application is hosted by a web farm or cluster, ensure that <machinekey> configuaration specifies the same validation kety and validation algorithm. Autogenerated cannot be used in a cluster.
Validation of viewstate MAC failed error
Root Cause
This exception appears because Controls using DataKeyNames require Viewstate to be encrypted. When Viewstate is encrypted (Default mode, Auto, is to encrypt if controls require that, otherwise not), Page adds <input type="hidden" name="__VIEWSTATEENCRYPTED"
id="__VIEWSTATEENCRYPTED" value="" /> field just before closing of the <form> tag.
But this hidden field might not have been rendered to the browser with long-running pages, and if you make a postback before it does, the browser initiates postback without this field (in form post collection). End result is that if this field is omitted
on postback, the page doesn't know that Viewstate is encrypted and causes the aforementioned Exception. I.E. page expects to be fully-loaded before you make a postback.
Please check our
previous discussion about this issue, I think the workaroud is also available for you,
Best regards
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Validation of Viewstate MAC failed. If this application is hosted by a web farm or cluster, ensure that <machinekey> configuaration specifies the same validation kety and validation algorithm. Autogenerated cannot be used in a cluster.
Validation of viewstate MAC failed error
Root Cause
This exception appears because Controls using DataKeyNames require Viewstate to be encrypted. When Viewstate is encrypted (Default mode, Auto, is to encrypt if controls require that, otherwise not), Page adds <input type="hidden" name="__VIEWSTATEENCRYPTED"
id="__VIEWSTATEENCRYPTED" value="" /> field just before closing of the <form> tag.
But this hidden field might not have been rendered to the browser with long-running pages, and if you make a postback before it does, the browser initiates postback without this field (in form post collection). End result is that if this field is omitted
on postback, the page doesn't know that Viewstate is encrypted and causes the aforementioned Exception. I.E. page expects to be fully-loaded before you make a postback.
Please check our
previous discussion about this issue, I think the workaroud is also available for you,
Best regards
You're working for Microsoft, and basicly what you're telling here is that ASP.NET has a serious bug, there's no solution other than some workarounds disabling some security features!!!
Instead of these workarounds, I suggest to add a machinekey in the web.config file. The Machinekey is used to encrypt/decrypt the viewstate. By default, the machinekey is autogenerated, but whit this default setting, when the application pool recycles, a
new key is generated, which cannot decrypt the viewstate encrypted with the previous generated key resulting in this error. Specifying a machinekey will ensure that on each an every request, even after the applicatoon pool recycles, the same key is used. To
generate a machine key, use this online tool
By the way. this also solves unexpected logouts when using forms authentication, because the authenticaton ticket is also decrypted/encrypted using the machinekey
Member
457 Points
250 Posts
Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 23, 2013 07:34 AM|Tamizhiniyan Natarajan|LINK
I am developing a website in AS.net and its worked well on web server also. But , this application causes the following error while didn.t browse any functionality in browser after half hour.
Validation of Viewstate MAC failed. If this application is hosted by a web farm or cluster, ensure that <machinekey> configuaration specifies the same validation kety and validation algorithm. Autogenerated cannot be used in a cluster.
I think its a configuration error?? Help me pls??
Contributor
4240 Points
3250 Posts
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 23, 2013 07:42 AM|smiling4ever|LINK
Are you on load balanced servers?
Are you loading webforms using ajax in your page?
Member
457 Points
250 Posts
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 23, 2013 01:30 PM|Tamizhiniyan Natarajan|LINK
No.... I am using normal C# code. No Ajax and jquery....
Contributor
4240 Points
3250 Posts
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 23, 2013 01:32 PM|smiling4ever|LINK
Ok, your issue is coming from one page i guess, post the code here and let me check
All-Star
52793 Points
9695 Posts
MVP
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 25, 2013 10:39 AM|Ruchira|LINK
Hello,
Try the resolutions here - http://support.microsoft.com/default.aspx?scid=kb;en-us;555353&sd=rss&spid=6351
Please 'Mark as Answer' if this post helps you
My Tech BlogMember
680 Points
279 Posts
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 26, 2013 01:54 AM|Tear09|LINK
Hi,
There are some related thread.
http://forums.asp.net/t/955145.aspx/1/10?PageIndex=20
http://forums.asp.net/t/1166634.aspx
Thanks
All-Star
32817 Points
3815 Posts
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 26, 2013 02:55 AM|Angie xu - MSFT|LINK
Hi Tamizhiniyan
Validation of viewstate MAC failed error
Root Cause
This exception appears because Controls using DataKeyNames require Viewstate to be encrypted. When Viewstate is encrypted (Default mode, Auto, is to encrypt if controls require that, otherwise not), Page adds <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" /> field just before closing of the <form> tag.
But this hidden field might not have been rendered to the browser with long-running pages, and if you make a postback before it does, the browser initiates postback without this field (in form post collection). End result is that if this field is omitted on postback, the page doesn't know that Viewstate is encrypted and causes the aforementioned Exception. I.E. page expects to be fully-loaded before you make a postback.
Please check our previous discussion about this issue, I think the workaroud is also available for you,
Best regards
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
All-Star
25756 Points
7014 Posts
Re: Validatio of viewstate MAC failed. While publishing website in Webserver.
Aug 26, 2013 03:14 AM|hans_v|LINK
You're working for Microsoft, and basicly what you're telling here is that ASP.NET has a serious bug, there's no solution other than some workarounds disabling some security features!!!
Instead of these workarounds, I suggest to add a machinekey in the web.config file. The Machinekey is used to encrypt/decrypt the viewstate. By default, the machinekey is autogenerated, but whit this default setting, when the application pool recycles, a new key is generated, which cannot decrypt the viewstate encrypted with the previous generated key resulting in this error. Specifying a machinekey will ensure that on each an every request, even after the applicatoon pool recycles, the same key is used. To generate a machine key, use this online tool
http://aspnetresources.com/tools/machineKey
By the way. this also solves unexpected logouts when using forms authentication, because the authenticaton ticket is also decrypted/encrypted using the machinekey