Description
openedon Dec 5, 2023
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When refreshing a Blazor page that has @attribute [Authorize]
, the browser gives a HTTP 401, even though the user is logged in.
Similar to #52317, but we're not using a custom auth provider. We're using MS Entra ID as per the .NET 7 docs https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-microsoft-entra-id?view=aspnetcore-7.0. This issue was introduced when migrating the project to .NET 8.
Expected Behavior
It should load the page.
Steps To Reproduce
dotnet new blazorwasm -ho -au SingleOrg --api-client-id "{api-client-id}" --app-id-uri "{app-id-uri}" --client-id "{client-id}" --default-scope "API.Access" --domain "{domain}" -o "Project" --tenant-id "{tenant-id}" --framework net7.0
- Migrate to .NET 8 as per https://learn.microsoft.com/en-us/aspnet/core/migration/70-80?view=aspnetcore-8.0&tabs=visual-studio#convert-a-hosted-blazor-webassembly-app-into-a-blazor-web-app
- Add
@attribute [Authorize]
to a page. - Go to page, refresh browser.
Exceptions (if any)
No response
.NET Version
8.0.100
Anything else?
The article https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-microsoft-entra-id?view=aspnetcore-7.0 was removed from the .NET 8 docs.
I've read #52317 (comment), but it's not clear how that applies to MS Entra ID auth, and since there's no documentation on this scenario anymore, It's not clear what to do.
Prerendering is disabled:
App.razor
<HeadOutlet @rendermode="new InteractiveWebAssemblyRenderMode(prerender: false)"/>
...
<Routes @rendermode="new InteractiveWebAssemblyRenderMode(prerender: false)" />
My App.Razor is in the server project, my Routes.Razor is in the Client project