Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am going through problem with Antiforgery __RequestTokenVerification not Present.

Am not getting this exception on the page or in application.

But using zap tool and run it i can see the exception in the event viewer.

I have use the attribute [HttpZPost], [ValidateAntiForgeryToken] in my controller and use the @Html.AntiforgeryToken() in all the view forms.

using jQuery and ajax call send data to server
JavaScript
$.fn.executeCommand = function(command, action) {
    $(this).each(function() {
        $(this).click(function() {
            action = action || $(this).data("action") || $(this).attr('href');
            var form = $("<form method='post' action='" + action + "'><input type='hidden' name='CommandName' value='" + command + "'></form>").appendTo($("body"));

            $('<input />').attr('type', 'hidden')
                .attr('name', "__RequestVerificationToken")
                .attr('value', $('#__AjaxAntiForgeryForm input[name=__RequestVerificationToken]').val())
                .appendTo(form);

            form.submit();
            return false;
        });
    });
};

Please help out how to resolve it.
Regards
sarfaraz
Posted
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900