blazorblazor-server-sideasp.net-core-3.0

How to disable Blazor server side pre-render?


To disable server side pre-render on asp.net core preview 3, you just needed to comment @(await Html.RenderComponentAsync<MyApp>()).

Since asp.net core preview 4, when you comment this line, the page doesn't render and on the main component @page "/", the tag <app> remains blank.

So, how can we disable server side pre-render ?


Solution

  • Finally found a solution by cores-system in github Source: https://github.com/aspnet/AspNetCore/issues/9584#issuecomment-485257261

    app.UseEndpoints(endpoints =>
    {
       endpoints.MapBlazorHub().AddComponent<App>(selector: "app");
       endpoints.MapFallbackToFile("index.html"); // or - endpoints.MapFallbackToPage("/_Host");
    });
    

    Hope this works...