Url generation overrides ambient area value

1 Answer 129 Views
General Discussions
Chris
Top achievements
Rank 1
Chris asked on 14 May 2022, 08:21 AM

I have just updated some of my code to 2022 R2 and believe I have found a bug. It is not control specific as it is related to the DataSource and the way it generates urls.

In my code I have controllers and views within a MVC Area (Areas in ASP.NET Core | Microsoft Docs )

Up to now it worked fine and the below sample would end up generating a url that used the ambient area when generating the url

.Read(read => read.Action("Transactions_Read", "Transactions").Data("transreaddata"))

This would produce: /Admin/Transactions/Transactions_Read

Now since R2 2022 it will not use the ambient Area. Thus it will produce: /Transactions/Transactions_Read

 

Current workaround would be to add an area route value in for each url.  If one has lots of datasources where that would be necessary that could be a bit time consuming. May be classified as a breaking change

 

Doing some debugging on it with the actual telerik source code I have found the problem

In file NavigatableExtensions.cs with the function GenerateUrl (line 160)

The below was added between R1 2022 and R2 2022

 

object area;
            if (navigatable.HasValue() && navigatable.RouteValues != null && !navigatable.RouteValues.TryGetValue("area", out area))
            {
                navigatable.RouteValues.Add("area", "");
            }

Effectively, if you rely on using ambient values, you do not create a route value called "area". Thus the TryGetValue fails and causes the code to adda blank area route value which will override the ambient value

 

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 18 May 2022, 10:25 AM

Hello Chris,

Thank you for the extensive feedback. It is greatly appreciated.

Indeed, this is a bug , and it is already logged in the kendo-ui-core repo, and it is currently in progress. You can follow the status here:

https://github.com/telerik/kendo-ui-core/issues/6840

While the official fix is provided, it will be needed to pass the area as a route value:

.DataSource( source => source
        .Ajax()
        .Read(read => read.Action("Transactions_Read", "Transactions", new { area = "MyArea"}).Data("transreaddata"))
 )

Аs a token of gratitude, I have updated the points in your Telerik account for reporting the details of the bug.

Please accept our apologies for the inconvenience caused. If any further questions regarding the matter arise, you are more than welcome to let me know.

 

Regards, Mihaela Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Anuruddhi
Top achievements
Rank 1
commented on 15 Jun 2022, 01:01 PM

Can I know when will this issue get a fix? Because of this routing issue, We can't upgrade our telerik version with latest version without adding area route value to all our existing code. Which is a very hectic task. 
Mihaela
Telerik team
commented on 15 Jun 2022, 02:15 PM

Hi Anuruddhi,

The issue is fixed and will be available in the next SP (R2 2022 SP1).

Chris
Top achievements
Rank 1
commented on 15 Jun 2022, 04:23 PM

Alternatively, (if you can't wait and is what I have done),

1. download the source for the net core version

2. Find the function in the file NavigatableExtensions.cs and modify it so as to remove what was added (see my original post)

3. Compile it and then manually reference the dll in your project (delete the nuget reference)

4. Just remember to put it back to the nuget reference when the bug fix is out

Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or