dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.53k stars 25.3k forks source link

Tutorial results in an error on first run #25584

Closed bradygaster closed 2 years ago

bradygaster commented 2 years ago

Upon following the tutorial through to the end, the article has an error on the F5 experience. When the StateHasChanged() method fires in Index.razor, there's a threading issue resulting with the error message:

System.InvalidOperationException: 'The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.'

I'm working on a resolution to this issue and a resolution to the continuing issue related to following this tutorial in the context of an authentication-enabled version of the Blazor Server project as reported in this tweet.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

guardrex commented 2 years ago

I assigned myself in case you just want to post the update information in a comment. Otherwise, please re-assign if you plan to work it to a PR.

btw ....

to the continuing issue related to following this tutorial in the context of an authentication-enabled version of the Blazor Server project

Per MS tutorial guidelines, the fix for an auth-enabled scenario that isn't within the scope of the tutorial's learning objectives probably should go into one of the SignalR reference topics and then is cross-linked from this tutorial topic in its additional resources. They like to keep the tutorials focused on the scenario at hand ... minimal extra info ... minimal extra links ... minimal notes ... etc.

joe_friday

"All we want are the facts, sir." Sgt. Joe Friday (Jack Webb), [Dragnet]() ©1949-59 NBCUniversal

bradygaster commented 2 years ago

Whilst I generally concur with you on this one, I'd almost argue that for a "next step" article beyond this one that would teach customers how to add the auth layer using the tools or CLI and then how to implement the naming provider to use the authenticated user's username.

Seems like a great opportunity to carry on from this article.

BTW, i think the fix for this is simply:

InvokeAsync(StateHasChanged);

Instead of

StateHasChanged();
bradygaster commented 2 years ago

@guardrex I adore the giffery btw. thanks for being awesome.

stay-awesome-im-out

guardrex commented 2 years ago

I recommend an issue for a new tutorial if you'd like it. Then DR/Artak can figure out how to proceed ... who writes it ... when ... etc.

I'll see if I can square this issue away first thing Monday morning.

bradygaster commented 2 years ago

Groovy! Quick intro to @jcjiang, who will be leading the charge on SignalR things with me over the next few months and beyond.