The required anti-forgery form field “__RequestVerificationToken” is not present Error in user Registration

后端 未结 19 1283
旧巷少年郎
旧巷少年郎 2020-11-29 22:12

I am using Membership.create user function, then the following error is occurring,

The required anti-forgery form field \"__RequestVerifi

19条回答
  •  感动是毒
    2020-11-29 22:33

    Make sure in your controller that you have your http attribute like:

    [HttpPost]
    

    also add the attribute in the controller:

    [ValidateAntiForgeryToken]
    

    In your form on your view you have to write:

    @Html.AntiForgeryToken();
    

    I had Html.AntiForgeryToken(); without the @ sign while it was in a code block, it didn't give an error in Razor but did at runtime. Make sure you look at the @ sign of @Html.Ant.. if it is missing or not

提交回复
热议问题