3

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 ?

4

2 回答 2

2

终于在github中通过cores-system找到了解决方案来源: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");
});

希望这有效...

于 2019-04-21T17:21:45.627 回答
1

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

要禁用预渲染,请打开Pages/_Host.cshtml文件并将render-modeComponent Tag Helper 的属性更改为 Server: CSHTML

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

Pages/_Layout.cshtml 中禁用了内容的预呈现:CSHTML

<component type="typeof(HeadOutlet)" render-mode="Server" />
于 2021-11-09T13:52:19.690 回答