How to convert a Blazor version 7 Server to version 8 InteractiveServer #54580
Unanswered
DavidThielen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all;
I just went through this and the painful part was figuring out what to do. Once I had that, actually doing it is pretty fast and easy. So for those of you facing the same thing, here it is. And this includes
[CascadingParameter] Task<AuthenticationState>
Take the contents of App.razor, remove the outer
<CascadingAuthenticationState>
and paste that as the contents of the newly created Routes.razor. Then changeAppAssembly="@typeof(App).Assembly"
toAppAssembly="@typeof(Program).Assembly"
.Old App.razor
New Routes.razor
In Program.cs, replace:
with:
and replace (after UseAuthentication(); UseAuthorization();):
with:
Finally, you copy _Host.cshtml to App.razor, and then delete _Host.cshtml. When doing this, delete the code around xsrf in App.razor.cs and _Host.cshtml - this is all now handled by the call app.UseAntiforgery().
I am not going to list everything below because the few changes will got lost in the stuff that didn't change. So the below is what changed.Pay close attention to as it's a subtle but critical change!
Change source in _Host.cshtml:
to the new (overwrite old content) App.razor:
Beta Was this translation helpful? Give feedback.
All reactions