title: Get the Route Template from IOwinContext
body: <p>I am looking to get the route template from a request. I am using OwinMiddleware and am overriding the Invoke method accepting the IOwinContext.</p>
  
  <pre><code>public override async Task Invoke(IOwinContext context)
  {
      ...
  }
  </code></pre>
  
  <p>Given the Request URL: <a href="http://api.mycatservice.com/Cats/1234" rel="noreferrer">http://api.mycatservice.com/Cats/1234</a></p>
  
  <p>I want to get "<strong>Cats/{CatId}</strong>"</p>
  
  <p>I have unsuccessfully tried converting it using the following approachs:</p>
  
  <pre><code>HttpRequestMessage msg = new HttpRequestMessage(new HttpMethod(context.Request.Method), context.Request.Uri);
  
  HttpContextBase httpContext = context.Get&lt;HttpContextBase&gt;(typeof(HttpContextBase).FullName);
  </code></pre>
  
  <h2>For reference:</h2>
  
  <p>Here is a <a href="https://stackoverflow.com/questions/25222277/web-api-get-route-template-from-inside-handler#answer-25275874">post about how to do this using HttpRequestMessage</a> which I have successfully implemented for another project</p>