WebApplication.UseStatusCodePages() cannot handle unauthorized requests without explicit UseAuthorization() call
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] 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_
Contributor guide
Assessment
This issue has not been assessed yet.