Skip to content

DynamicRouteValueTransformer - Continues to search for routes #22601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joestant opened this issue Jun 5, 2020 · 2 comments
Closed

DynamicRouteValueTransformer - Continues to search for routes #22601

joestant opened this issue Jun 5, 2020 · 2 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing
Milestone

Comments

@joestant
Copy link

joestant commented Jun 5, 2020

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.

@pranavkm pranavkm added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jun 5, 2020
@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone Jun 10, 2020
@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jun 10, 2020
@mkArtakMSFT
Copy link
Contributor

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we will planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@DrSoops
Copy link

DrSoops commented Jul 9, 2020

Adding my personal use case (which I could see being a generic use case as it grows) to this topic.

In my case I have a few routes that need to be handled differently but have the same url structure.
Routing patterns

endpoints.MapDynamicControllerRoute<HealthTransformer>("/{controller}/{area}/Health");
endpoints.MapDynamicControllerRoute<GenericTransformer>("/{controller}/{area}/{action}");

Sample requests

Controller/Foo/Health
Controller/Bar/Action

In this case anything that ends with Health should be treated as a Health check and will have a generic implementation where the latter will have extra logic to route to the correct controller and action.
It would be very beneficial to have the same built in routing precedence that already exists for non-dynamic routing.
Currently as @joestant mentioned both DynamicRouteValueTransformer are being executed.

@javiercn javiercn added Done This issue has been fixed and removed Working labels Aug 26, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Sep 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing
Projects
None yet
Development

No branches or pull requests

5 participants