79581572

Date: 2025-04-18 18:59:05
Score: 1
Natty:
Report link

I was having the same issue in .NET 9 Blazor and worked around it by avoiding the @attribute and using <AuthorizeView> to wrap the page instead. This seems to have allowed the authorization logic to kick in and hydrate by current authorization state properly [we happened to be using Okta/OIDC].

Gave 401 on direct access:

@attribute [Authorize(Policy="FooPolicy")]

Showed appropriate page:

<AuthorizeView Policy="FooPolicy">
  <Authorized>
    ... existing page content...
  </Authorized>
  <NotAuthorized>
    <h3>Access Denied</h3>
  </NotAuthorized>
</AuthorizeView>
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @attribute
  • User mentioned (0): @attribute
  • Low reputation (1):
Posted by: TheJet