I think we need to come up with a strategy or some diagnostics to help people migrate from the preview 7 template to the preview 8 one.
Since we're removing stateful prerendering, there are two changes you need to make in your app:
_Host.cshtml use RenderStaticComponentAsync Startup.cs add a mapping for the component to the <app> elementBefore
```C#
app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
**After**
```C#
app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub<App>("app");
endpoints.MapFallbackToPage("/_Host");
});
The problem is that it's really easy to get the first one of these right - but once you do, the app stops responding. You'll prerender just fine, but no websocket will be opened. There are literally NO diagnostics telling you that you forgot to do the second part of this.
We need to consider whether we have any good ideas to help people understand how to update preview 4->preview 8
Isnt that a job for the Obsolete Attribute? I.e. add it to the non-generic MapBlazorHub method.
And what happens if we don't want to map Blazorhub to a specific component like App inside an app html tag?
Like when we build a web site using MVC/Razor Pages and want to embed blazor components inside those projects.
-Preview7 I tried using RenderStaticComponentAsync method and the interactivity inside my razor pages stopped working.
-Preview8 Latest Nightly build: Also failing to render interactive blazor components in my razor pages using RenderStaticComponentAsync
Regards!!
d it to the non-generic
MapBlazorHubmethod.
Yup. That's an option. At this point we'd just remove the no-args method wholesale.
Even better @rynowak. Let the compiler error out is a very clear signal to users something's needs changing 😎
Doesn't this break the embeding of components in existing MVC/RazorPages projects?
How will these be registered in preview-8 ?
You must also consider multiple "entry point" components for existing MVC/Razor pages projects.
For example:
I have a razor page Index.cshtml, and I want to render a component in there, for example
<counter>@(await Html.RenderStaticComponentAsync<Counter>())</counter>
while having a second page called Whatever.cshtml, in which I want to render a different component in there, like:
<whatever-component>@(await Html.RenderStaticComponentAsync<WhateverComponent>())</whatever-component>
Currently in preview 7 everything works fine when using
endpoints.MapBlazorHub();
How will this work after the changes ?
Yes. that will still work.
That is good to hear, because in preview-7 it doesn't work.
If you try to add multiple entry points in an MVC/Razor Pages app, when you navigate to a page that do not contain one of the custom tags (e.g. <counter>), then you get "not found" errors in blazor.server.js and it blows up.
OK, we should fix that then. Is there an existing issue for that?
I didn't find anything searching in the repo's issues. I will create an issue, if you want, tomorrow morning (GMT +3 timezone ) ☺
Thanks!
Issue created: https://github.com/aspnet/AspNetCore/issues/12795
😀
Most helpful comment
You must also consider multiple "entry point" components for existing MVC/Razor pages projects.
For example:
I have a razor page
Index.cshtml, and I want to render a component in there, for examplewhile having a second page called
Whatever.cshtml, in which I want to render a different component in there, like:Currently in preview 7 everything works fine when using
How will this work after the changes ?