asp.net-core - Asp.Net Core 2.1 在 Head 标签之间使用 ViewComponents 动态获取元数据
问题描述
我想从管理面板动态地将元数据添加到 SEO 的布局页面。样本:
<meta content="" name="description" />
<meta content="XXX" name="author" />
在 MVC5 中,我使用:
<head>
@Html.Action("GetMetatags", "Home")
</head>
并轻松获得它们。但是在 Asp.Net Core 2.1 中,我尝试使用 ViewComponents 而不是像这样的局部视图:
<head>
@await Component.InvokeAsync("MetaDatasForSEO")
</head>
问题:我可以正确获取元数据,但不能在<head>
标签之间。只是在<Body>
标签中......所以它不起作用。感谢帮助...
解决方案
推荐阅读
- c# - 通过一个 .NET5 微服务(应用程序)访问多个 Gmail 帐户
- java - 更新查询在preparedStatements Java中不起作用
- c - 如何在链接器文件中添加堆内存
- ionic-framework - 我正在尝试在离子应用程序中制作侧面菜单。但是侧边菜单的链接没有点击
- node.js - 应用程序之间通过 docker 网络的 dokku 内部连接
- javascript - 如何从对象中获取对应的key和value,并将其转换为数组对象
- firebase - 如何阻止堆栈中的两个小部件相互重叠?
- javascript - 在 ReactJS 中隐藏条件文本
- c++ - 以下代码的时间复杂度是多少?
- azure-data-explorer - Partition an unpartitioned table in ADX