title: Check if requestee can access another route C# DotNet Core
body: <p>I want to use Hateoas in my C# Web Api.  I want to be able to work out if the requestee has access to other routes by providing the route name.</p>
  
  <ol>
  <li>When the requestee calls /A and would pass <code>PolicyB</code> but not <code>PolicyC</code>, I want them to receive "Get" back, not "Post"</li>
  <li>When the requestee calls /A and would pass <code>PolicyB</code> and <code>PolicyC</code>, I want them to receive "Get" and "Post" back</li>
  </ol>
  
  <p>Here is the example code:</p>
  
  <pre><code>public class AController : Controller
  {
      [HttpGet("A", Name = "RouteA")]
      public IActionResult GetA()
      {
          IEnumerable&lt;string&gt; routesAbleToAccess = MethodsUserCanAccessForRoute("RouteB");
          return Ok(routesAbleToAccess);
      }
  
      [HttpGet("B", Name = "RouteB")]
      [Authorize("PolicyB")]
      public IActionResult GetB()
      {
          return Ok();
      }
  
  
      [HttpPost("C")] // Also named Route B
      [Authorize("PolicyC")]
      public IActionResult SaveC()
      {
          return Ok();
      }
  
      private IEnumerable&lt;string&gt; MethodsUserCanAccessForRoute(string route)
      {
          // logic to get the routes that the user can access
      }
  }
  </code></pre>