question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service to recalculate endpoint to execute with endpoint routing

See original GitHub issue

Is there a way to cause endpoint routing to re-calculate the endpoint that is to be executed? Perhaps as a service in DI?

My Scenario: I have a middleware that is often registered after UseRouting. During request processing I have the need to re-write the request so it changes the request path (e.g. from /foo to /bar), but once the next middleware is executed which eventually ends up at UseEndpoints we get a 404 due to the now mismatched path.

I’d love a service in DI to help with this that I can trigger from my middleware.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
javiercncommented, Mar 4, 2021
if("/my/original/path"){
  var endpoint = context.GetEndpoint();
  if(endpoint == null){
    // Execute default response logic
  }else{
    if(endpoint.Metadata.OfType<MyMetadata>().Any())
    {
      // let the endpoint override an execute
    }else
    {
      throw InvalidOperationException("Overriden by mistake.");
    }
  }
}
0reactions
msftbot[bot]commented, May 19, 2021

Thank you for contacting us. Due to a lack of activity on this discussion issue we’re closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn’t been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using 'UseMvc' to configure MVC is not supported while ...
For EnableEndpointRouting , it uses EndpointMiddleware to route the request to the endpoints. Share.
Read more >
Routing in ASP.NET Core
Discover how ASP.NET Core routing is responsible for matching HTTP requests and dispatching to executable endpoints.
Read more >
What is Endpoint Routing, Implementing it from start [with ...
In this tutorial I will explain Endpoint routing from the beginning with working code. Endpoint routing is a new concept in ASP.
Read more >
Understanding ASP.NET Core Endpoint Routing | aregcode
The endpoint route resolution is the concept of looking at the incoming request and mapping the request to an endpoint using route mappings....
Read more >
ASP.NET Core Series: Endpoint Routing - YouTube
ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud ready, connected applications In this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found