title: See which controller and action will be executed from a route?
body: <p>In ASP .NET Core, how can I given a route (for instance <code>/api/users/28</code>) see which controller will be used, and which action will be used? In this case for instance, it would be <code>UsersController</code> and its <code>Get(int id)</code> action.</p>
  
  <p>I would love if there was a way to access some kind of router that could tell me this, so that I don't have to replicate the internal routing system myself. I just haven't been able to find this using the official documentation on ASP .NET Core routing.</p>
  
  <p><strong>Edit 1</strong> My question is not a duplicate. I'm not looking for options on determining if a route exists - I want to know what exact action and controller will handle it.</p>
  
  <p><strong>Edit 2</strong> Here's what my current code looks like, and what I've tried:</p>
  
  <pre><code>var httpContext = new DefaultHttpContext();
  httpContext.Request.Path = "/api/users/28";
  httpContext.Request.Method = "GET";
  
  var context = new RouteContext(httpContext);
  
  //throws an exception: AmbiguousActionException: Multiple actions matched.
  var bestCandidate = _actionSelector.SelectBestCandidate(context,
      _actionDescriptorCollectionProvider.ActionDescriptors.Items); 
  </code></pre>