title: Inheriting route attribute in .NET Core Web API
body: <p>Let say I am going to make the following REST APIs:</p>
  
  <p><code>https://somedomain.com/api/Companies/{cid}</code></p>
  
  <p><code>https://somedomain.com/api/Companies/{cid}/Employees/{eid}</code></p>
  
  <p><code>https://somedomain.com/api/Companies/{cid}/Products/{pid}</code></p>
  
  <p>In the above situtaion, I need routing (<code>Route()</code> Attribute) to be extendable so that a routing hierarchy can be formed. I have tried different approach but all of them don't seem decent. Anyone can give me advice on how can I achieve <code>routing inheritance</code> like...</p>
  
  <pre><code>    [Route("api/CompaniesController/{cid}")]
      [ApiController]
      public class CompaniesController : ControllerBase
      {
      }
  
      [Route("Employees/{eid}")]
      public class EmployeesController: CompaniesController 
      {
          [HttpGet]
          public IEnumerable&lt;string&gt; Get()
          {
              return new string[] { "value1", "value2" };
          }
      }
  
      [Route("Products/{pid}")]
      public class ProductsController: CompaniesController 
      {
          [HttpGet]
          public IEnumerable&lt;string&gt; Get()
          {
              return new string[] { "value1", "value2" };
          }
      }
  </code></pre>