Aspnetcore: MapDynamicControllerRoute doesn't work with DefaultLinkGenerator

Created on 11 Nov 2019  路  10Comments  路  Source: dotnet/aspnetcore

Describe the bug

The DefaultLink Generator (and the AnchorTagHelper) do not work when mapping dynamic routes. They do not find any routes and produce a null href.

To Reproduce

  1. create a vanilla mvc site
  2. add one dynamic route
  3. use the anchor tag helper or the LinkGen class
  4. Result is href is null.

see v simple example here.

https://github.com/ollieferns/dynamiclinkgenissue

Further technical details

  • ASP.NET Core version 3.1 (preview)
    .NET Core SDK (reflecting any global.json):
    Version: 3.1.100-preview2-014569
    Commit: 4bd5d24d87

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.100-preview2-014569/

Host (useful for support):
Version: 3.1.0-preview2.19525.6
Commit: 5672978d91

.NET Core SDKs installed:
3.0.100 [/usr/local/share/dotnet/sdk]
3.1.100-preview1-014459 [/usr/local/share/dotnet/sdk]
3.1.100-preview2-014569 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0-preview1.19508.20 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0-preview2.19528.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0-preview1.19506.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0-preview2.19525.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

affected-medium area-mvc enhancement feature-routing investigate severity-blocking

Most helpful comment

@javiercn @rynowak I cloned the source and had a look. The issue appears to me to be in RouteValuesAddressScheme around line 104

var metadata = endpoint.Metadata.GetMetadata<IRouteNameMetadata>();

Because the endpoint is a IDynamicEndpointMetadata not a IRouteNameMetadata it doesnt consider the route. I made IDynamicEndpointMetadata inherit from IRouteNameMetadata as a fix. It fixed my issue but made 3 tests fail. If I get to the bottom of the issue, how would I go about submitting a PR? I would rather like this fixed. In the meantime, what is the best way of referencing my altered MVC assemblies instead of the default ones for my own project?

All 10 comments

@ollieferns thanks for contacting us.

@rynowak can you look into this?

@javiercn @rynowak I cloned the source and had a look. The issue appears to me to be in RouteValuesAddressScheme around line 104

var metadata = endpoint.Metadata.GetMetadata<IRouteNameMetadata>();

Because the endpoint is a IDynamicEndpointMetadata not a IRouteNameMetadata it doesnt consider the route. I made IDynamicEndpointMetadata inherit from IRouteNameMetadata as a fix. It fixed my issue but made 3 tests fail. If I get to the bottom of the issue, how would I go about submitting a PR? I would rather like this fixed. In the meantime, what is the best way of referencing my altered MVC assemblies instead of the default ones for my own project?

Hi, any chance of a quick answer to this while the issue is being looked at?
" In the meantime, what is the best way of referencing my altered MVC assemblies instead of the default ones for my own project?"

Is there an easy way to do this? Or do I need to add the MVC projects to my solution?

Thanks,
O

@rynowak @javiercn could I get a response to my questions at least if there is no progress? thanks

@rynowak @javiercn could somebody reach out to me please regarding this issue. It seems to me to be a fairly serious issue with endpoint routing. Happy to discuss privately if required but the total radio silence is a bit unnerving when trying to convince my powers-that-be that .net core and aspnet is a viable technology choice for what we are trying to do here.

So as an update this still does not work in .NET 5.01 Preview. How depressing. No answers to my questions for 4+months and no fix.

Same issue here, see Stack Overflow. Is there an update? Would a PR for this be considered?

Thanks for suggesting help, @MaxHorstmann.
It's not clear at the moment what the fix would look like here as we haven't yet investigated this.
@javiercn do you have something on mind about this for @MaxHorstmann to consider?

I鈥檓 really glad to hear that this is being evaluated for .NET 5.0.0. In the meanwhile, at minimum, it鈥檇 be useful to acknowledge this limitation in the documentation. It took me a bit to isolate this behavior and discover this issue.

(If I have a chance, I can look into submitting a PR for the documentation鈥攖hough I鈥檒l need to investigate the conventions for documenting feature limitations, as I鈥檓 not clear how that鈥檚 generally handled.)

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Was this page helpful?
0 / 5 - 0 ratings