Skip to content

DynamicRouteValueTransformer - Continues to search for routes #22601

@joestant

Description

@joestant

I have implimented the DynamicRouteValueTransformer for CMS pages within VS2019 Preview and .Net 5.0.0 4.20257.10.

Some CMS pages are suffixed, such as /reviews/ or /job-adverts/ etc.

To get around this i've implemented two MapDynamicContollerRoutes

endpoints.MapDynamicControllerRoute<CmsRequestTransformer>("/{companyname}/{action:regex(^(reviews|job-adverts)$)}/{id?}");
endpoints.MapDynamicControllerRoute<CmsRequestTransformer>("/{**slug}");

However, when the first route is found it will continue to the next...
The {**slug} won't find it as these CMS pages - in theory don't exist in the CMS. (I could inject them in though, but would multiply many routes within the cache. the companyname could be anything and be added or removed at any time).

Is there anway to check if a route has already been found or prevent the second route firing? This is doing another look up, hitting my cache. I'd like to prevent this by a simple found check. I have looked far and wide to no avail.

Background -
To prevent the {**slug} issue I have used the known work around, ActionResult route filters. Which is working. The only routing I have within UseEndpoints is my DynamicRouteValueTransformer.
Why am I doing this? I'm migrating an application from MVC 5 .Net 4.7.2 that used
var routes = RouteTable.Routes; using (routes.GetWriteLock()) {..... this was used to update the CMS after the website is compiled.

DynamicRouteValueTransformer seems the best option for .net 5. I'm handling many routes with no hints such as /blogs or /article, and if they do have a category, the category is from the CMS.

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-routing

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions