5

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 ?

Alexandre
  • 7,004
  • 5
  • 54
  • 72

2 Answers2

3

According to MS Docs: https://learn.microsoft.com/en-us/aspnet/core/blazor/state-management?view=aspnetcore-6.0&pivots=server#handle-prerendering

To disable prerendering, open the Pages/_Host.cshtml file and change the render-mode attribute of the Component Tag Helper to Server: CSHTML

<component type="typeof(App)" render-mode="Server" />

Prerendering of content is disabled in Pages/_Layout.cshtml: CSHTML

<component type="typeof(HeadOutlet)" render-mode="Server" />
Brydon
  • 123
  • 11
2

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...

enet
  • 41,195
  • 5
  • 76
  • 113