Fix SignOutSessionStateManager compilation error for .NET 11+#5086
Fix SignOutSessionStateManager compilation error for .NET 11+#5086LoopedBard3 merged 4 commits intomainfrom
Conversation
Update LoginDisplay.razor in both blazorpizza and blazorpizzaaot scenarios to use conditional compilation. For .NET 11+, use the new Navigation.NavigateToLogout() method. For .NET 8-10, continue using the deprecated SignOutSessionStateManager for backward compatibility. Co-authored-by: LoopedBard3 <15679138+LoopedBard3@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes compilation errors in the Blazor Pizza application when targeting .NET 11+ by adding conditional compilation support for the removed SignOutSessionStateManager API. The changes enable the app to build successfully across multiple .NET versions (net8-net10 using the legacy API, net11+ using the new NavigateToLogout() method).
Changes:
- Introduced code-behind files (
LoginDisplay.razor.cs) for both blazorpizza and blazorpizzaaot scenarios - Added conditional compilation directives to support both legacy and new authentication APIs
- Migrated code from inline
@codeblocks to separate code-behind files
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/scenarios/blazorpizza/src/BlazingPizza.Client/Shared/LoginDisplay.razor | Removed inline @Inject directives and @code block, delegating to code-behind |
| src/scenarios/blazorpizza/src/BlazingPizza.Client/Shared/LoginDisplay.razor.cs | New code-behind file with conditional compilation for .NET 11+ compatibility |
| src/scenarios/blazorpizzaaot/src/BlazingPizza.Client/Shared/LoginDisplay.razor | Removed inline @Inject directives and @code block, delegating to code-behind |
| src/scenarios/blazorpizzaaot/src/BlazingPizza.Client/Shared/LoginDisplay.razor.cs | New code-behind file with conditional compilation for .NET 11+ compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,28 @@ | |||
| using Microsoft.AspNetCore.Components; | |||
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | |||
There was a problem hiding this comment.
Missing using directive for System.Threading.Tasks. The Task type used in the async BeginSignOut method (line 22) requires an explicit using directive. Other files in this project (e.g., OrdersClient.cs, Program.cs) explicitly include this using statement, and it should be added here for consistency and to ensure compilation succeeds across all target frameworks, especially when implicit usings may not be enabled.
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | |
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | |
| using System.Threading.Tasks; |
| @@ -0,0 +1,28 @@ | |||
| using Microsoft.AspNetCore.Components; | |||
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | |||
There was a problem hiding this comment.
Missing using directive for System.Threading.Tasks. The Task type used in the async BeginSignOut method (line 22) requires an explicit using directive. Other files in this project (e.g., OrdersClient.cs, Program.cs) explicitly include this using statement, and it should be added here for consistency and to ensure compilation succeeds across all target frameworks, especially when implicit usings may not be enabled.
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | |
| using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | |
| using System.Threading.Tasks; |
|
There are now 2 errors affect some of the other tests. The two localized app runs are hitting: The Minimum Blazor Template and the New Blazor Template are hitting this error: The Minimum Blazor and New Blazor are both being hit on main. It is not clear why the BlazorLocalized one started or if it is still going. |
SignOutSessionStateManagerwas removed in .NET 11, breaking Blazor Pizza app builds. This PR adds conditional compilation to support both the legacy API (net8-net10) and the newNavigateToLogout()method (net11+).Changes
Updated LoginDisplay.razor (both
blazorpizzaandblazorpizzaaotscenarios):SignOutSessionStateManageronly for net8-net10NavigateToLogout()extension method for net11+Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
6s7vsblobprodcus313.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)bcnvsblobprodcus378.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)kh4vsblobprodcus325.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)mfjvsblobprodcus373.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)p2ovsblobprodcus312.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)s4uvsblobprodcus326.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)ukkvsblobprodcus352.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)vwvvsblobprodcus334.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)x3yvsblobprodcus370.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)ytvvsblobprodcus310.vsblob.vsassets.io/usr/bin/dotnet dotnet build BlazingPizza.sln -f net8.0(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
When trying to build the Blazing Pizza app in src/scenarios/blazorpizza/src we are hitting the following error:
e\app\BlazingPizza.Client\Shared\LoginDisplay.razor(2,9): error CS0246: The type or namespace name 'SignOutSessionStateManager' could not be found (are you missing a using directive or an assembly reference?) [\e\app\BlazingPizza.Client\BlazingPizza.Client.csproj::TargetFramework=net11.0]with a fuller log being as follows: