.net6 中 Blazor PageTitle 設置無效的解決方法

直接在 razor 頁面裏添加 <PageTitle>xxx</PageTitle> 標籤無效時的解決方法

For using the <PageTitle> tag with the new version of .NET Core, server-side and not webAssembly, you need replace your <title> tag with a new component and add his library into the file Pages/_Host.cshtml.

@using Microsoft.AspNetCore.Components.Web

<head>
  <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>

 

Project scafolding created from .Net Core 6 add these parts automatically in Pages/_Layout.cshtml

Teorically, users with migrating WebAssembly projects need add too the code on below in Program.cs

builder.RootComponents.Add<HeadOutlet>("head::after");

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章