Enhancements on LinkGenerator and TemplateBinder #19395
Labels
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
Status: Resolved
Milestone
Is your feature request related to a problem? Please describe.
Ambient Value Invalidation is one of breaking changes from Endpoint Routing.
With the current algorithm, anchor links for
/[area=project]/{projectid}/[controller=...]/[action=...]
is more complicated. I have to attachasp-route-projectid="some..."
to each tag.After I read the source code for
Microsoft.AspNetCore.Routing.Template.TemplateBinder
, I found that ifprojectid
can be added into_requiredKeys
, this problem will no longer exists.Describe the solution you'd like
Create a new Attribute for Endpoint Metadata, which contains the route tokens to add into
_requiredKeys
. And when generatingTemplateBinder
s, use these attributes to build that array.Additional context
Well, if I make the
_requiredKeys
an empty array through reflection, it will become the behavior in ASP.NET Core 2.1 and earlier. Maybe an alternative compatibility property inMvcOptions
also works? This really slow down my work for upgrading to ASP.NET Core 3.x. And the solution in the second section doesn't really bother the Endpoint Routing system.The text was updated successfully, but these errors were encountered: