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

Cannot upgrade to 2020.1 because of AntiForgeryToken

3 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 29 Jan 2020, 03:49 PM

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

3 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 31 Jan 2020, 10:52 AM

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.
0
Alberto
Top achievements
Rank 1
answered on 31 Jan 2020, 11:26 AM

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

0
Alberto
Top achievements
Rank 1
answered on 04 Feb 2020, 07:34 AM

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

Tags
Grid
Asked by
Alberto
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Alberto
Top achievements
Rank 1
Share this question
or