title: Dynamic authorization of roles asp.net core
body: <p>This is not a duplicate question or rather the solutions given in other solutions have not worked.</p>
  <p>Lets say there is a controller</p>
  <pre><code>[Authorize(Roles=//set dynamically)]
  public IActionResult DashBoard(LoginModel model)
  {
  }
  </code></pre>
  <p>I have tried the solutions in the following questions</p>
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/30099613/dynamically-add-roles-to-authorize-attribute-for-controller"> Add roles to authorize attribute</a></p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/40302117/dynamically-assign-controller-action-permissions-to-roles-in-asp-net-mvc"> dynamically assign controller action permissions to roles</a></p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/33076266/dynamically-add-roles-to-authorize-attribute-for-controller-in-asp-net-5">dynamically add roles to authorize attribute for controller</a> (Error: Handle method - no suitable method found to override )</p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/37247094/can-policy-based-authorization-be-more-dynamic">can policy based authorization be more dynamic</a></p>
  </li>
  </ol>
  <p>All of these solutions do not work as either the methods overridden in the interfaces are not present (eg. authorizeAttribute does not contain a definition for AuthorizeCore) or in some cases IServiceCollection services does not contain a particular method</p>