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.
<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”.
1) ViewResult : Used to return a view to render html in the browser. this is the most common used action result
2)PartialViewResult: Similar to view result, it returns a partial view.
3) ContentResult: Used to return any type of content. By default it is used to return plain text but the actual content type can be explicitly defined
4) EmptyResult: this is equivalent to void method,it is by definition an action result object,but it does nothing.
5)FileResult:Used to return binary content.
6)HttpUnauthroizedResult: You can return an HttpUnauthrized result when the request tries to access restricted content that, for example its not available to anonymous user.
9)RedirectRresult:Used to perform an HTTP redirect to another URL.you can define it as temporary (code 302) or permanent (code 301) HTTP redirect.
10)RedirectToRouteResult: used to perform an HTTP redirect ,but to specific route rather than a URL
The error message “The requested page cannot be accessed because the related configuration data for the page is invalid in MVC” is occurred due to invalid code in the web.config file. Invalid code in the sense you may given a invalid tag like for <connectionString> you may given <constr>. it makes the error we should use the current xml tag names.
Please see the below examples
Actual tag code for connection string
you may be made mistake like
See the above example the ‘S’ letter for the two example is different because the web.config file xml tags are case sensitive. it should follow the visual studio rules to avoid errors.
In web.config xml file we should specify the tags currently according to the visual studio needs.
if anything wrong in the web.config file you will get the error like
The requested page cannot be accessed because the related configuration data for the page is invalid in MVC