-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I really hope that I'm doing something wrong and missing an obvious solution because otherwise this seems like a big oversight.
I've spent a lot of time customizing Blazor identity UI in a razor class library only to find that as soon as I wanted to host my Blazor app outside of the root (/), identity stopped working. Although my application enables interactive render mode Server, everything I have done so far is SSR.
I then created a default Blazor app using the Blazor Web App with Authentication type Individual Accounts to test whether or not my changes were causing the problems. As it turned out, the identity pages also don't work in the default app if you change the base path.
I made two changes:
App.razor:<base href="/test/" /> in App.razor
Program.cs: app.UsePathBase("/test"); added right after var app = builder.Build();
With that change, the identity pages like Login will display but all POSTs result in HTTP 405 Method Not Allowed errors. Also, the "Auth Required" page fails with an exception that authorization is not enabled. So, my next step was to add app.UseAuthorization();
Adding that line causes the "Auth Required" page to redirect to /Account/Login (without /test/ in the url) which allows the log in to work! But Logout is broken and so are all of the Manage pages once you try to POST by clicking a button.
Similar issues related to UsePathBase, but not mentioning Blazor identity UI:
#57843 (closed as Duplicate but the duplicate link is 404)
#59638
Expected Behavior
Blazor identity UI should work whether an application is installed at the root of a website or if the application is installed in IIS as an Application under the Default website.
Steps To Reproduce
Create a new project with template "Blazor Web App"
- Authentication type: Individual Accounts
- Interactive render mode: Server
- Interactivity location: Per page/component
Install the application in a non-root website.
Run the application and try to use the identity UI pages.
Exceptions (if any)
No response
.NET Version
10.0.103
Anything else?
No response