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

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

    In my case it was due to adding requireSSL=true to httpcookies in webconfig which made the AntiForgeryToken stop working. Example:

    
      
    
    

    To make both requireSSL=true and @Html.AntiForgeryToken() work I added this line inside the Application_BeginRequest in Global.asax

        protected void Application_BeginRequest(object sender, EventArgs e)
      {
        AntiForgeryConfig.RequireSsl = HttpContext.Current.Request.IsSecureConnection;
      }
    

提交回复
热议问题