About "Use non-routable components in pages or views"

Akhmad Hamzah S 0 Reputation points
2023-11-17T10:18:26.3966667+00:00

Excuse me, i use ASP.Net Core MVC then i use Blazor as component for user interface. Which mean for route using controller in MVC feature and user interface using Blazor component.

.Net 8 has released. So i have intents to use feature "Interactive Auto".

So i read document about that (https://learn.microsoft.com/en-us/aspnet/core/blazor/components/integration?view=aspnetcore-8.0&source=docs#use-non-routable-components-in-pages-or-views).

But i have confused at configuration in Program.cs. At this section "app.MapRazorComponents<App>().AddInteractiveServerRenderMode();".

Because i don't use "App.razor". What should i do for replace the "App"?

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | Blazor
Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,086 Reputation points Volunteer Moderator
    2023-11-17T17:49:58.45+00:00

    To create a Blazor UI you need a Blazor root component, which by convention is named App.razor. you should use the name of your root UI component. Not sure what you just don't use App.razor.

    in .net 8 razor components can be static (server rendered only). this allows a razor page or MVC view to render html with a razor component. as these are static any client interactive UI must be done in javascript.

    you also of the option of the component being a server pre-render, then use a signal/r hub back to the hosted blazor app. the docs explain how to add the hub support to the MVC or razor page layout.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.