Solved: The anti-forgery token could not be decrypted


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

.

Again and again, error by mistake I encountered while behaving with the ASP.NET MVC project I'm working on. Understand it, I am not a programmer, just happened to work in this field.

Pay attention to this error message:

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.

Very interesting is not it? If you are experiencing the same thing, hopefully this can be the right solution for you. Why hope? Because of what I learned, there are several factors that lead to the mistake "The anti-forgery token could not be decrypted" is happening. So, hopefully the problem you are facing is the same as what I experienced. If not, you can try to look for other references.

One thing I noticed was that this error could be caused by some @Html.AntiForgeryToken() code in one page. I have 2 @Html.AntiForgeryToken() code in my page, and once I remove one of them, this error is gone.

Conclusion

So, the error "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 <plugin explicit configuration explicit encryption and validation keys. "AutoGenerate can not be used in a cluster." happens because I have two @Html.AntiForgeryToken() code on one page. I just need to remove one of them, and all resolved.

6425 Views