title: How to add custom authorization attribute to AuthorizeView?
body: <p>I am rewriting a WebForms app to Blazor.  The current system uses the numbers 1 through 5 to show the user's 'access level' to indicate which menu items/webpages they have access to.</p>
  <p>I have created a custom authorization attribute to support this access level functionality (temporarily). The new attribute follows Microsoft's guidance:  <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authorization/iauthorizationpolicyprovider?view=aspnetcore-5.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/security/authorization/iauthorizationpolicyprovider?view=aspnetcore-5.0</a></p>
  <p>The attribute [AccessLevelList(&quot;4&quot;, &quot;5&quot;)] works in the WebAPI. When I try it in the client NavMenu  to limit menu item visibility, I cannot find the proper syntax for it to work. Anything else results in the attribute not being found or it will not compile.</p>
  <p>I have tried Policy='AccessLevelList(&quot;4&quot;, &quot;5&quot;)', but this requires the single-quotes which results in the <em>string value</em> of the attribute being passed directly to the authorization policy provider rather than the attribute being passed to the <em>attribute</em> class.</p>
  <p>Update 7/19/21:
  <strike>Any suggestions on making this work?</strike>
  Since the Policy attribute requires a string value, how do I get the AuthorizeView to accept my new custom attribute directly?</p>
  <p>Update 7/20/21:
  Successfully created a custom AuthorizeView component:
  <code>&lt;CustomAuthorizeView AccessLevelList=&quot;4,5&quot;&gt;</code> and using the AuthenticationState I am able to validate the user's claim against the required claims. How do I notify that the user is not authorized to view the menu item so that the render fragment is not displayed?  Do I have to create a custom AuthenticationStateProvider?</p>