0

I'm trying to implement breadcrumb functionality into my project by parsing the route for actions. My goal is to scan all methods with the [HttpGet] attribute and generate breadcrumbs for them.

I want to access the route information for an action at startup. For example:

[Route("example/{controller}/some-action")]
public async Task<IActionResult> MyAction()

Is it possible for me to get this route string "example/{controller}/some-action" at startup? One way to do this is to scan the assembly for Route attributes and grab the value from there but the route can be specified in multiple ways such as having part of the route on the controller and another part on the action, or even using another tag such as [HttpGet("")].

Is there anything in asp core that will allow me to generate the route template for an action on startup? I obviously don't expect values in the string, just the actual string template itself.

boxedi
  • 23
  • 2
  • 3
  • 1
    https://stackoverflow.com/questions/28435734/how-to-get-a-list-of-all-routes-in-asp-net-core/66086633#66086633 – abdusco Sep 16 '21 at 12:41

0 Answers0