Skip to content

WebApplication.UseStatusCodePages() cannot handle unauthorized requests without explicit UseAuthorization() call #49515

Open
@marinasundstrom

Description

@marinasundstrom

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

These are observations from implementing auth with Server-side rendered pages (SSR) in Blazor Preview 6 - using Razor components instead of MVC Razor pages.

Cookie auth just works, that is great. But there are some issues:

Issues:

  • AuthorizeRouteView doesn't work with the router. The NotAuthorized fragment does not get rendered. Instead I get redirected to a layout-less page saying: Error: 401 Unauthorized.

  • The LoginDisplay doesn't re-ender when logged in using form. Redirecting to another page would help here.

Questions:

  • How do I redirect to another URL from a component that server render? NavigationManager of course doesn't work here.

My github repo (branch): https://github.com/marinasundstrom/Blazor8Test/tree/auth

Expected Behavior

When unauthorized and entering page that requires authorization,
I expect the NotAuthorized fragment to be rendered with the MainLayout.

Steps To Reproduce

https://github.com/marinasundstrom/Blazor8Test/tree/auth

Exceptions (if any)

No response

.NET Version

8.0.100-preview.6.23330.14

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-hostingIncludes Hostingarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions