Cannot upgrade to 2020.1 because of AntiForgeryToken

4 posts, 0 answers
  1. Alberto
    Alberto avatar
    20 posts
    Member since:
    May 2019

    Posted 29 Jan 2020 Link to this post

    Hi There,

    I've upgraded my ASP.NET MVC website from Kendo 2019 to 2020.1 and suddenly the Kendo.Grid got broken (no data loaded). The first thing I noticed, was the browser error: "Uncaught ReferenceError: getAntiForgery is not defined". (see attached screenshot)

    After investigating some hours, I've discovered that I need to remove the .Data("getAntiForgery") call from my View and the [ValidateAntiForgery] attribute from controller actions to be able to resume the Kendo grid functionalities. (see attached screenshots)

    Can anybody explain me why?

    Thanks,

    Alberto

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1236 posts

    Posted 31 Jan 2020 Link to this post

    Hello Alberto,

    The error observed states that the getAntiForgery() function could no longer be found on the page where the Grid is loaded. Have you altered the contents of that page/the scripts loaded? In order to be able to assist you with that, I will also need to reproduce the issue locally. Therefore, I would like to ask you to prepare and send me a small isolated runnable sample replicating the error in question. Please, remove any external dependencies and database calls from that project and use sample data created within the app.

    Regards,
    Veselin Tsvetanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
  3. Alberto
    Alberto avatar
    20 posts
    Member since:
    May 2019

    Posted 31 Jan 2020 in reply to Veselin Tsvetanov Link to this post

    Hi Veselin,

    Have you altered the contents of that page/the scripts loaded?

    I've noticed that some calls to @Scripts.Render("~/bundles/jquery"), @Scripts.Render("~/bundles/jquery") were not present in your examples, so I removed them even from my templates. Are you referring to this?

    I'm not sure I will be able to isolate the problem. I guess it's not safe to remove those AntiForgery attributes. What I don't understand it is why it was working in Kendo 2019 till today.

    Thanks,

    Alberto

  4. Alberto
    Alberto avatar
    20 posts
    Member since:
    May 2019

    Posted 04 Feb 2020 Link to this post

    Hi Veselin,

    I discovered what the problem was. I was missing this call: @Scripts.Render("~/bundles/custom") here:

    <link href="https://kendo.cdn.telerik.com/2020.1.114/styles/kendo.fiori.min.css" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/bootstrap.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/bootstrap.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
     
    @Scripts.Render("~/bundles/custom")

     

    I'm attaching the *.js file for your reference. The issue can be closed.

    Thanks,

    Alberto

Back to Top