include antiforgerytoken in ajax post ASP.NET MVC

后端 未结 11 2407
感动是毒
感动是毒 2020-11-22 14:00

I am having trouble with the AntiForgeryToken with ajax. I\'m using ASP.NET MVC 3. I tried the solution in jQuery Ajax calls and the Html.AntiForgeryToken(). Using that solu

11条回答
  •  醉话见心
    2020-11-22 14:30

    I tried a lot of workarrounds and non of them worked for me. The exception was "The required anti-forgery form field "__RequestVerificationToken" .

    What helped me out was to switch form .ajax to .post:

    $.post(
        url,
        $(formId).serialize(),
        function (data) {
            $(formId).html(data);
        });
    

提交回复
热议问题