title: Getting Route Name in WebAPI (NOT MVC)
body: <p>I have a controller that is using WebAPI, <strong>NOT</strong> MVC. It is a REST service.</p>
  <p>If I have a method defined like this, is there any way I can get the <code>Name</code> property from the route that was used to reach my method?</p>
  <pre><code>[HttpPost]
  [Route(&quot;api/batches/{clientguid}/cancel/{loanguid}/&quot;, Name = &quot;cancel&quot;)]
  [Route(&quot;api/batches/{clientguid}/reopen/{loanguid}/&quot;, Name = &quot;reopen&quot;)]
  [Route(&quot;api/batches/{clientguid}/dne/{loanguid}/&quot;, Name = &quot;dne&quot;)]
  [Route(&quot;api/batches/{clientguid}/paid/{loanguid}/&quot;, Name = &quot;paid&quot;)]
  public bool ManuallySetFeeStatusForLoan(string clientguid, string loanguid, [FromBody] FeeManualStatusInfo data) {
      try {
          switch (SomeWayToGetRouteName()) {
              case &quot;cancel&quot;: 
                  DoSomethingCancelly();
                  break;
              case &quot;reopen&quot;: 
                  DoSomethingReopeny();
                  break;
              case &quot;dne&quot;: 
                  DoSomethingDNEy();
                  break;
              case &quot;paid&quot;: 
                  DoSomethingPaidy();
                  break;
              default:
                  return false;
                  break;
          }
  
          return true;
      } catch (Exception ex) {
          Data.LogEx(ex);
          Library.ThrowWebException(ex);
          return false;
      }
  }
  </code></pre>
  <p>So what I'm stuck on is the <code>SomeWayToGetRouteName()</code> bit for the <code>switch</code> statement.
  I saw someone propose this solution on <a href="https://stackoverflow.com/questions/39621674/multiple-routes-assigned-to-one-method-how-to-determine-which-route-was-called">a similar question</a>:</p>
  <p><code>var requestedView = this.ControllerContext.ActionDescriptor.AttributeRouteInfo.Name</code></p>
  <p>but near as I can tell, that is specific to MVC, and is not available in WebAPI.
  It barfs on the <code>ActionDescriptor</code> property.</p>