Skip to content

Blazor Authorization - AuthorizeRouteView and RedirectToLogin not working. #52063

Open
@christallire

Description

@christallire

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I've created Blazor WebApp via VS 2022 template with individual identity.
No matter what I do, <AuthorizeRouteView> and <NotAuthorized> are not working and redirect any request to /Account/Login. putting <p>not working</p> doesn't help.

Expected Behavior

<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
            <NotAuthorized>
                <p>not authorized</p>
            </NotAuthorized>
        </AuthorizeRouteView>
        <FocusOnNavigate RouteData="@routeData" Selector="h1" />
    </Found>
</Router>

Prints "not authorized" when you click "Auth Required" in the template app

image

Steps To Reproduce

  1. Create Blazor Web App with Server Interactive render mode, and with Individual Account Authentication type.
  2. Replace from "<RedirectToLogin />" to "<p>not authorized</p>" in Routes.razor (to see if your redirection is from RedirectToLogin component)
  3. Click "Auth Required" in template app.

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

This is a blocker since I was migrating .NET 7.0 app to .NET 8.0, but It behaves very differently.

Metadata

Metadata

Assignees

Labels

DocsThis issue tracks updating documentationarea-authIncludes: Authn, Authz, OAuth, OIDC, Bearerfeature-identity-ui

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions