-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Closed
Copy link
Labels
Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.The author of this issue needs to respond in order for us to continue investigating this issue.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issueIndicates that the team needs a repro project to continue the investigation on this issuearea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Whom it may concerned,
My project is upgrading to Net 8 and using @attribute [Authorize]
. when I logged out and called NotifyAuthenticationStateChanged method by using CustomAuthenticationStateProvider and then it threw an exception, please see below:
Razor Page
@attribute [Authorize]
...
Code behind:
- ClaimsPrincipal anonymous = new(new ClaimsIdentity());
- NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(anonymous)));
- return Task.CompletedTask;
Exception:
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Collection was modified; enumeration operation may not execute.
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.Generic.List`1.Enumerator[[Microsoft.AspNetCore.Components.Rendering.ComponentState, Microsoft.AspNetCore.Components, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNextRare()
at System.Collections.Generic.List`1.Enumerator[[Microsoft.AspNetCore.Components.Rendering.ComponentState, Microsoft.AspNetCore.Components, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
at Microsoft.AspNetCore.Components.CascadingValueSource`1.<>c__DisplayClass10_0[[System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Components.Authorization.AuthenticationState, Microsoft.AspNetCore.Components.Authorization, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<NotifyChangedAsync>b__0()
at Microsoft.AspNetCore.Components.WebAssembly.Rendering.NullDispatcher.InvokeAsync(Action workItem)
at Microsoft.AspNetCore.Components.CascadingValueSource`1[[System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Components.Authorization.AuthenticationState, Microsoft.AspNetCore.Components.Authorization, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].NotifyChangedAsync()
at Microsoft.AspNetCore.Components.CascadingValueSource`1[[System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Components.Authorization.AuthenticationState, Microsoft.AspNetCore.Components.Authorization, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].NotifyChangedAsync(Task`1 newValue)
at Microsoft.Extensions.DependencyInjection.CascadingAuthenticationStateServiceCollectionExtensions.AuthenticationStateCascadingValueSource.HandleAuthenticationStateChanged(Task`1 newAuthStateTask)
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
NET 8
Anything else?
No response
lcetinapta, Ali1Jamal, gyurisicSSPS, uottoni, Blaisor and 4 more
Metadata
Metadata
Assignees
Labels
Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.The author of this issue needs to respond in order for us to continue investigating this issue.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issueIndicates that the team needs a repro project to continue the investigation on this issuearea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components