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.
It uses now a web farm ? If yes and using "in process" session variables, you need a load balancer that takes care to forward requests from a given source always to the same server.
AFAIK most balancers allows that (for example on Azure you can chose).
If you have no choice then you'll likely have to change the session provider (for example a db or whatever) so that even if the user is directed to another server, it can still use the same session variables.
Edit: BTW I try to use them as less as I can and if possible as a "browser session scoped cache" ie they are not accessed directly but exposed behind a strongly typed facade that loads them as needed. Avoid to load a session variable on one page and having
another page to require this session variable being set from elsewhere. Avoid to store in a session variable a value that couldn't be reloaded if needed to first check if this is a load balancing problem.
Member
54 Points
419 Posts
Validation of viewstate MAC failed - Session Variables does not work properly!!!
Sep 04, 2019 01:01 PM|bsarahim|LINK
Hello All
Website is hosted in the hosted provider
Out of sudden we are getting this 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.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3429.0
We did the follow
<pages enableEventValidation="false" viewStateEncryptionMode="Never">
But still the same error
2. Added in the EnableViewStateMac="false" and True as well in the each asp.net pages
But still the same error
3. After adding this in the web.config
<machineKey validationKey='6EBA439D3D866111346C4A00FF0C90D68CF93B93C970A6026AA58A57745D1EE360256C3ACAF5FD475CD1AA1FF63F713A9311B3A962041B4502A891DA47355F22' decryptionKey='A00232E968FBD9E601226F6194C64C52383B8756C43BC5FC' validation='SHA1'/>
The error is gone.. But session variables are not working properly.. Sometimes it works, some it time not..We cant remove session variables
Pls Suggest.. Thanks
All-Star
48510 Points
18071 Posts
Re: Validation of viewstate MAC failed - Session Variables does not work properly!!!
Sep 04, 2019 02:30 PM|PatriceSc|LINK
Hi,
It uses now a web farm ? If yes and using "in process" session variables, you need a load balancer that takes care to forward requests from a given source always to the same server.
AFAIK most balancers allows that (for example on Azure you can chose).
If you have no choice then you'll likely have to change the session provider (for example a db or whatever) so that even if the user is directed to another server, it can still use the same session variables.
Edit: BTW I try to use them as less as I can and if possible as a "browser session scoped cache" ie they are not accessed directly but exposed behind a strongly typed facade that loads them as needed. Avoid to load a session variable on one page and having another page to require this session variable being set from elsewhere. Avoid to store in a session variable a value that couldn't be reloaded if needed to first check if this is a load balancing problem.
For now check the IIS log or use maybe https://docs.microsoft.com/en-us/dotnet/api/system.environment.machinename?view=netframework-4.8 and Session.SessionID to see if you stay on the same server and check you still uses the same session.
Member
54 Points
419 Posts
Re: Validation of viewstate MAC failed - Session Variables does not work properly!!!
Sep 06, 2019 04:23 PM|bsarahim|LINK
Thanks..
I have verified there is no web farms or cluster.
Any idea how to fix it?
How to store session variables in Database (session provider) or any other alternatives.. pls let me know.. Thanks
Contributor
3710 Points
1043 Posts
Re: Validation of viewstate MAC failed - Session Variables does not work properly!!!
Sep 09, 2019 08:20 AM|Yongqing Yu|LINK
Hi bsarahim,
To fix this issue, I suggest you can check your session state first, make sure if you have changed session state and provide us with information.
Second, you can update the value of your machineKey to restore session.
For this question, you can follow these steps:
For more step details, you could refer to this link :
HOW TO: Configure SQL Server to Store ASP.NET Session State
Best Regards,
YongQing.
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.