asp.net-mvckendo-uikendo-ui-mvckendo-window

AntiForgeryToken in MVC


I am opening an kendo window using the below jquery function.

I need to pass __RequestVerificationToken to the MVC Controller because I am having ValidateAntiForgeryToken Attribute.

However, I am not able to pass it. Can you please suggest how to pass __RequestVerificationToken while opening an kendoWindow

function OpenTest() {               
    var url = '@Url.ActionWithArea("OpenTest", "Test", GlobalConst.AREA_Test)';
    url += "?test=" +$("#test").val() + "&test1=" +$("#test1").val();

    windowElement = $('<div id = "abc" />').kendoWindow({
        title: 'test',
        content: url,
        modal: true,
        resizable: false,
        draggable: false, 
        width: 900,
        height: 400,
        close: function () {              
                windowElement.destroy(); 
            }).data("kendoWindow").center().open();
            return false;
        }
}

Solution

  • You will need to make a POST request when loading the template which would allow you to send your antiforgery token:

    content: {
        url: url,
        type: 'POST',
        data: {
            '__RequestVerificationToken': 'the value of your token'
        }
    },