prabodha
prabodha

Reputation: 3

Validation of viewstate MAC failed on Single Server Environment

Recently migrated our .net 4.0 web application to .net 4.7.2. Setting up the Dev environment and it is not a web farm scenario. The machine key is not auto generated also. Hit the 'Validation of viewstate MAC failed' error on Login page button click. MAC validation always fails in IE and in Chrome only once or twice a day.

Web.config :

<machineKey decryptionKey="F4B786E157C86740A610D....ghfghhgfh3F5C69,IsolateApps" validationKey="80DAFD9....3hgfhgfAC1CDD71B66820B664160337A4C6179C6C1480C8DA6EFD3C17D34B7BCE11A4ED8C02DD0F...3EC5556C4029084A8871,IsolateApps" validation="AES"/>

Tried the following;

  1. removed the action tag in form
  2. turned off macValidation in web.config
  3. regenerated the machine key
  4. at app pool set 'Virtual Memory Limit' to 0 and 'Load User Profile' to true

but no luck.

Error:

An unexpected error has occurred on this page and it has been logged. Please feel free to contact us with the information listed below:

GUID: feee9d30-5c42-4130-ad8b-174c14ba9dad

Machine Name Date URL 
ZZZ 12/Jun/2019 16:15:22 http://ZZZ:8080/UserManagement/Login.aspx 
-------------------------------------
Error Message : Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that 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.

Source : System.Web

Target Method: Void ThrowError(System.Exception, System.String, System.String, Boolean)

Stack Trace : at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) at System.Web.UI.HiddenFieldPageStatePersister.Load() at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

-------------------------------------
Error Message : Invalid viewstate. Client IP: nn.nmn.nn.nn Port: 56640 Referer: http://ZZZ:8080/UserManagement/Login.aspx Path: /UserManagement/Login.aspx User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729) ViewState: N9AFLjJRk5zRjomBHUnBhKTyeeYZgPslJ2437+N8XNzq3+7stdsP1XrS7CU94lXL8m7fvnx50FxdNnBBD2q4Z3HIwMhvup84vACt8nRedbvA/9iTx22OHG00rTvNu3jVRe5KHZXbZI6mK1EULS62LJ0N1eDYe+cZ9KdN80EeMiwvJSeSNKipb+JFPdLVoBtDRs3I7FOcNcEN5MSS6vriyquXN8x6xwRF8zkm4Q7g1KL827Nhu1DGwuF9rd2UYL923eMv5ChZmgnyLFZHoj+QvvMo73NfeTilhM8wuUvex0uCmR/oK4cdq3gUPdwxTPsCbWarFwOJr17nTwVeFFKrdudAZwIPVmvJWqCcBP3wWChSG/7gh0MQu+LOWJ80WL8IeM5CAT4cF8toDzsnHrsEoDuXwksB65Lz741ATcE2l8PUFwrMLnRCXEVKfv8Mz/ohGRuOih2fbM19RviuGvpjPc6Z+8nbh3OjFiAbj7vAvWXXV2cbxXpHUnH25RdiFBtkzQx6DJKGg4uRLDXYEBygOlPB4gk+hj3Ld8mKcnWap3WHj6GMibDdh9IbXEwMDDk6magEnPIrfClJM8YlWxd6mDShhxKJH1CQZvpC9KYMghzBt4KM/WtmGZ3fK9Aihtf9oX3W4HY45yAvSGsAMa27b74P8kY=

Upvotes: 0

Views: 5704

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12759

Below are the causes of MAC validation errors:

1.if your application is running in a farm (multi-server environment)

resolution:

  • enable affinity in the load balancer

2.check that which identity is used by your application pool,if IIS worker process uses the application pool identity it may cause the issue.

resolution:

  • Use the aspnet_regiis utility
  • Create an explicit element

3.Your application pool is set as LoadUserProfile=false

resolution:

  • Select application pool->go to the advanc esetting-> Set LoadUserProfile=true

enter image description here

4.The Page.ViewStateUserKey property has an incorrect value

Resolution:

  • Verify that ViewStateUserKey is set correctly

For more detailed solution you could refer Microsoft article: Resolving view state message authentication code (MAC) errors

Regards, Jalpa

Upvotes: 4

Related Questions