The anti-forgery token could not be decrypted error in ASP .Net MVC

The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.


The above error will happen when we have multiple AntiForgeryToken in same form and we try to submit the form Or any object that is submitting to action that has multiple AntiForgeryToken (This case will happen if we try to submit FormData or serialized data ) in case of ajax calls. This is a ASP MVC error it can happen while we creating forms.

For Example

<form id="dummy"  action="/Admin/Product/Create" method="post">


 <label  >Product Name</label>
 <input id="txtName" name="ProductName" type="text" placeholder="Product Name" >
 <button id="btnSave" name="btnSave" >Save</button>									


In the above example, we can see the form has two call to generate Anti Forgery Token so when we submit the form we will get the error “The anti-forgery token could not be decrypted”.


Leave a Reply