-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Blazor WASM] Upgrading project to .NET 8 and breaks [Authorize] Attribute #53075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
same problem, i use blazorWebView with windows forms and i have the same issue did you manage to fix it @patrickpham3339 ? |
Same here... |
Not yet… the issue’s still there.On Jan 25, 2024, at 7:55 AM, Ali Jamal ***@***.***> wrote:
same problem, i use blazorWebView with windows forms and i have the same issue did you manage to fix it @patrickpham3339 ?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hi @patrickpham3339. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
I also started getting this specific error with the same setup conditions (Blazor WASM on .NET 8). From the traces, and poking around at the source, it looks to be around the method CascadingValueSource.NotifyChangedAsync() :95 - :104:
Even though _subscribers itself has concurrency, the value is just a List<>. It's claimed the .Add is thread-safe, but perhaps for this specific condition it is not enough?
My complete stacktrace is:
|
Pardone, why completed? |
I have the same issue. |
Can confirm, this seems to only happen while using AddCascadingAuthenticationState() instead of the CascadingAuthenticationState component. The issue started occuring when I created a component in my layout that requested the cascading AuthState either from the CascadingParameter or the AuthorizeView. |
I have the same issue, on logging in. I too switched to the AddCascadingAuthenticationState() and had to revert back. not sure why this is closed... |
This problem also occurs in Blazor Server mode. Invoke of NotifyAuthenticationStateChanged throws System.Func`1 - "Collection was modified; enumeration operation may not execute" exception. |
Chiming in here - we've just seen the same issue. Reverting to |
Same issue here with
|
It looks like NotifyAuthenticationStateChanged() causes the error if there is an AuthorizeView tag. |
So, I need to downgrade to <CascadingAuthenticationState>? |
@javiercn is there a way to stop auto-closing this issue (until it's fixed)? |
Ok, I'm sorry @MackinnonBuck for bothering but this is bullshit. Forget about the wordaround, what kind of LTS is this when you introduce a new capability within this release, then find out that it does not work as intended and have it fixed in the next damn release? |
@thepra, we'll backport this if we get feedback that the .NET 9 fix fully addresses the problem. We're still in the prerelease phase for .NET 9, but we want to be cautious about changes we include in .NET 8 patch releases because the impact of introducing a regression is higher there. We're very keen on getting feedback on this fix so that we can backport it. When .NET 9 RC1 releases, it would help us if you (and others) could confirm that it fixes the problem in your scenario. Thanks for understanding! |
Sounds good, lets wait. |
Updated to 8.0.8 with the patched code, and if I nest an AuthorizeView, I still encounter the exception. If I revert back to the But, if I don't nest and only have 1 AuthorizeView, it does work and does not throw the error. So, it seems it's partially resolved. Also, I'm using WASM Standalone, so the Dispatcher is the NullDispatcher. And the AuthorizeView is used in my Header.razor component which is on the MainLayout.razor, but the nested AuthorizeView is only used in the Authorized fragment of the parent AuthorizeView, so it only throws upon successful login. Hope this feedback is helpful. |
Same issue in dotnet 8.0.10. Just wasted several hours on figuring how to fix it. Please reopen !!!!!!!!!!! |
Ran into this issue myself. Can confirm that updating to 9 resolved it. |
If .net9 has the fix, then it's really a great news :) |
This is not just related to WASM but Server as well. How is this closed? Problem remains in .net 8 and forcing us to upgrade to .net 9 is just wrong. program.cs
Then I have CustomAuthStateProvider which calls NotifyAuthenticationStateChanged when a customer logs in or out. The above throws the exception
removing this line
and reverting to
Resolved the problem. |
A janky temporary solution for me was to add a handler for the
|
The AddCascadingAuthenticationState doesn't work properly on dotnet 8.0, despite the docs indicating so. See dotnet/aspnetcore#53075
@MackinnonBuck Is there any news? |
@thepra, the .NET 8 fix will be included in an upcoming servicing release (most likely in March). |
Any updates on the lead time? I can see https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-8.0&tabs=visual-studio#troubleshoot-errors saying not to use to rap the but it's still the only solution. |
@VJayMeyer being hopeful, looking at the MR to backport this change, #57288 |
Is there an existing issue for this?
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:
Exception:
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
NET 8
Anything else?
No response
The text was updated successfully, but these errors were encountered: