-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Blazor Custom Route Constraints #28938
Copy link
Copy link
Open
Labels
Pillar: Complete Blazor Webaffected-fewThis issue impacts only small number of customersThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the futureFeatures related to the built in components we ship or could ship in the futurefeature-routingon-roadmapListed on the current release roadmapListed on the current release roadmapseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
Metadata
Metadata
Assignees
Labels
Pillar: Complete Blazor Webaffected-fewThis issue impacts only small number of customersThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the futureFeatures related to the built in components we ship or could ship in the futurefeature-routingon-roadmapListed on the current release roadmapListed on the current release roadmapseverity-minorThis label is used by an internal toolThis label is used by an internal tool
I am trying to use custom route constraint in Blazor, similar to how it currently works for both razor pages and MVC routes:
... but it appears that blazor route constraints do not consider any custom constraints that have been registered:
aspnetcore/src/Components/Components/src/Routing/RouteConstraint.cs
Lines 57 to 85 in af7c0cc
So I instead encounter the ArgumentException, "Unsupported constraint '{constraint}' in route '{template}'.".
It would be ideal if
RouteConstraintcould be modified to referenceRouteOptions.ContraintMapas the other routing engines do. Alternatively, needing to use some Blazor-specific registration method to register constraints only for Blazor would also be acceptable.