AntiForgeryToken in Grid

2 posts, 0 answers
  1. Nandan
    Nandan avatar
    15 posts
    Member since:
    Jun 2010

    Posted 27 Sep 2012 Link to this post

    • 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),

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

    if (addAntiForgeryToken)

    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.

  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 02 Oct 2012 Link to this post

    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:

    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!
Back to Top