If you have a
[ValidateAntiForgeryToken] attribute before the action. Then you also should add a
@Html.AntiForgeryToken() in the form.
In my case, I had below code in my web.config:
<httpCookies requireSSL="true" />
But my project was set to not use the SSL. So commenting out that line or setting up a project to always use the SSL solved it.
Please make sure that in your controller that you have the http attribute like:
Also add a attribute in a controller:
In your form on the view you have to write as below:
I had the Html.AntiForgeryToken(); without a @ sign while it was in the code block, it didn't give the error in Razor but did give at runtime. So make sure you look at the @ sign of @Html.Ant.. if it is missing there or not
If anyone is experiencing a error for the same reason why I experience it, then here's my solution:
If you had a
Then change it to