.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");

 

posted @   树欲静·而风不止  阅读(167)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2021-10-12 CentOS7 安装配置笔记 v2
点击右上角即可分享
微信分享提示