This is a migrated thread and some comments may be shown as answers.

AntiForgeryToken in Grid

1 Answer 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nandan
Top achievements
Rank 1
Nandan asked on 27 Sep 2012, 11:18 AM
  • Hi,
    We are using AntiForgeryToken in our application. For normal Ajax post currently we are using extension method for Ajax.BeginForm as follows:

public static MvcForm BeginForm(this AjaxHelper ajaxHelper, HtmlHelper htmlHelper, AjaxOptions ajaxOptions, bool addAntiForgeryToken = true, string actionName = null, string controllerName = null,
object routeValues = null, object htmlAttributes = null)
{
return htmlHelper.BeginFormWithAntiForgery(
() => ajaxHelper.BeginForm(actionName, controllerName, routeValues, ajaxOptions, htmlAttributes),
addAntiForgeryToken);
}

private static MvcForm BeginFormWithAntiForgery(this HtmlHelper htmlHelper, Func<MvcForm> formFunc, bool addAntiForgeryToken)
{
var form = formFunc();

if (addAntiForgeryToken)
htmlHelper.ViewContext.Writer.Write(htmlHelper.AntiForgeryToken().ToHtmlString());

return form;
}

Whenever Kendo grid is posting an Ajax request can we use the above extension method because this is the common code we have written. Seems like Kendo has its own way of sending an Ajax Request, how can we do changes in that. We want to do changes in the common method so that everything works fine.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 02 Oct 2012, 09:37 AM
Hello Nandan,

To send the AntiForgeryToken to the server when using Ajax binding I suggest you to use the approach covered in this forum thread:

http://www.kendoui.com/forums/ui/grid/kendo-grid-antiforgerytoken.aspx


All the best,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Nandan
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or