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”.
The view ‘Index’ or its master was not found or no view engine supports the searched locations. The following locations were searched:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
The problem will occurs when we trying to access an action in the controller. Consider the below action
|public class HomeController : Controller
public ActionResult Index()
The action index returns a view. Then it will check the corresponding view file in the following locations
Not only the location, it will check corresponding view with the action name that is Index is in our case, with following extensions
In the folder home or shared should contain a file with any of the extension above.
After creating the view in the specified folder the controller will get the correct view, then view will be shown in the page and we can avoid this error. This is one of the error we face when we start mvc projects. But is a basic thing in mvc in .net, it will understood this with in some days after starting study of mvc in .net.