Skip to content

[.NET 8] Using attribute [Authorize] is bugged when refreshing page (shows HTTP ERROR 401 despite being logged in) #52317

Closed
@DM-98

Description

@DM-98

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm using Blazor RenderMode InteractiveServer globally and Prerender turned off. I also use JWT authentication (not sure how it behaves with other authentication methods).

When navigating with a href clicks it works fine authenticating the user and showing authorized page. But when the same user refreshes the page with F5, it shows HTTP ERROR 401, like this:

71f6a2805720bc6e30fd8bc27805812a

A minimal reproducable project is made for you to see the issue.

Expected Behavior

I expect the authenticated & authorized user to keep seeing the Authorized content inside the blazor page component after a F5 page refresh.

Steps To Reproduce

  1. Download the repo: Minimalistic project - Github
    or quickly Git Bash this:
    git clone https://github.com/DM-98/BlazorApp2-AuthorizationIssueRepro
  2. Open Package Manager Console and run "Update-Database"
    (which makes a new database called BlazorApp2-AuthorizationBugRepro)
  3. Start with(out) debugging
  4. Register a user and then Login
  5. Navigate to [Authorize]'d page only and press F5

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions