Skip to content

Conversation

@brunomacharia
Copy link

Jtable ajax calls to controler actions marked with [ValidateAntiForgeryToken] may not work because Antiforgery checks the request header for an antiforgery token which is then compared with the cookies token. If they don't match or the token is missing, the server responds with error 400. All this is to prevent Cross-Site Request Forgery (CSRF) Attacks. This fix attempts to manage this by adding a security option where a antiforgerytoken can be passed, this is then added to the ajax call header for server side validation. usage would be like:

var token = 'gettokenvalue'
$('#CategoriesContainer').jtable(
{
title: 'Categories',
paging: false,
sorting: false,
security: {
antiforgerytoken: token
},
actions: {----------

bmacharia and others added 2 commits January 5, 2019 19:32
Jtable ajax calls to controler actions marked with [ValidateAntiForgeryToken]  may not work because Antiforgery checks the request header for an antiforgery token which is then compared with the  cookies token. If they don't match or the token is missing, the server responds with error 400. All this is to prevent Cross-Site Request Forgery (CSRF) Attacks. This fix attempts to manage this by adding a security option where a antiforgerytoken can be passed, this is then added to the ajax call header for server side validation. usage would be like:

 var token = 'gettokenvalue'
        $('#CategoriesContainer').jtable(
            {
                title: 'Categories',
                paging: false,
                sorting: false,
                security:
                {
                    antiforgerytoken: token
                },
                actions: {----------
@brunomacharia brunomacharia changed the title Add ASP.NET ValidateAntiForgeryToken fix Add ASP.NET ValidateAntiForgeryToken feature Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant