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

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

    In my case, I had this javascript on the form submit:

    $('form').submit(function () {
        $('input').prop('disabled', true);
    });
    

    This was removing the hidden RequestVerificationToken from the form being submitted. I changed that to:

    $('form').submit(function () {
        $('input[type=submit]').prop('disabled', true);
        $('input[type=text]').prop('readonly', true);
        $('input[type=password]').prop('readonly', true);
    });
    

    ... and it worked fine.

提交回复
热议问题