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

后端 未结 19 1257
旧巷少年郎
旧巷少年郎 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:41

    Like this:

    The Controller

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult MethodName(FormCollection formCollection)
    {
         ...
         Code Block
         ...
    }
    

    The View:

    @using(Html.BeginForm())
    {
         @Html.AntiForgeryToken()
         
         // rest
    }
    

提交回复
热议问题