Blazor WebAssembly Standalone App template in VS2022 17.9.2/Net 8.0.201 with MIP when published to Azure logout => 404 => '"undefined" is not valid JSON'' #54391
Labels
area-blazor
Includes: Blazor, Razor Components
bug
This issue describes a behavior which is not expected - a bug.
✔️ Resolution: Duplicate
Resolved as a duplicate of another issue
Status: Resolved
Is there an existing issue for this?
Describe the bug
Create a brand new Blazor WebAssembly Standalone App in latest VS2022 on latest Net Core 8 using the VS template steps, only additional step is adding pubxml and the login-callback auth url in Azure. Log-in log-out works fine localhost, but after publish log-in works but log out at first 404's and with fix noted in steps ends up at 'There was an error trying to log you in: '"undefined" is not valid JSON'' at the 'authentication/login-failed' route.
I've found several similar, e.g. #49956, but the trimming fix hasn't worked. The repro I have isn't anything complicated by upgrading or CI/CD pipelines so maybe it would be a good repro to proof the fix being proposed?
Expected Behavior
No error should be displayed after the redirect if the operation was successful.
Steps To Reproduce
Many steps just to be detailed; a repo wouldn't really help because you need to have a site set up in Azure and the clientid etc wouldn't be in repo. It's literally follow the latest VS2022 template, create a Static site to deploy to and publish to it:
VS2022 Create new project
Blazor WebAssembly Standalone App
[ProjectName]
Don't place in same directory
Net 8
MS Identity platform
Incl sample pages
Untick do not use top level
Create
VS2022 starts, required components pops up
Next
Create new App [ProjectName]
Don't add graph or another api
Leave Code, Nuget, Update app registration
Select Publish
Azure -> Next
Azure Static Web Apps -> Next
[ProjectName]
Free
Source: Other
LoginDisplay.razor exists in both Layouts and Shared - delete Shared
RedirectToLogin.razor exists in both Layouts and Shared - delete Shared
Build and run local
Log in
Log out
Works correctly
Build - Publish
Fails - Failed to setup project: EPERM: operation not permitted, open 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE.env'
Close VS and reopen
Build - Publish
Succeeds and site opens. Copy the [url]
Open portal.azure.com
Open Entra ID
Open App Registrations
Select [ProjectName]
In authentication add [url]/authentication/login-callback
Save
Back to [url] in browser
Log in works
Log out ->404 - not found [url]/authentication/logout-callback?state=[xxxx]
Add staticwebapp.config.json to wwwroot
https://www.justinjbird.me/2023/setting-up-404-redirect-for-hugo-using-azure-static-app/
Azure/static-web-apps-cli#754 (comment)
Back to [url] in browser
Log in works
Log out ->'There was an error trying to log you in: '"undefined" is not valid JSON'
Exceptions (if any)
Ofc maybe I've missed something obvious...
.NET Version
Net Core 8.0.201
Anything else?
VS2022 17.9.2
.NET SDK:
Version: 8.0.201
Commit: 4c2d78f037
Workload version: 8.0.200-manifests.5638171e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.201\
.NET workloads installed:
[maui-windows]
Installation Source: VS 17.9.34622.214
Manifest Version: 8.0.6/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.6\WorkloadManifest.json
Install Type: Msi
[android]
Installation Source: VS 17.9.34622.214
Manifest Version: 34.0.79/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.79\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: VS 17.9.34622.214
Manifest Version: 17.2.8022/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8022\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: VS 17.9.34622.214
Manifest Version: 17.2.8022/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8022\WorkloadManifest.json
Install Type: Msi
Host:
Version: 8.0.2
Architecture: x64
Commit: 1381d5ebd2
.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
6.0.321 [C:\Program Files\dotnet\sdk]
8.0.102 [C:\Program Files\dotnet\sdk]
8.0.200 [C:\Program Files\dotnet\sdk]
8.0.201 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
The text was updated successfully, but these errors were encountered: