gpt4 book ai didi

asp.net-mvc-5 - 使用MVC-5在“ View ”页面中添加元标记

转载 作者:行者123 更新时间:2023-12-03 22:48:02 27 4
gpt4 key购买 nike

我在_Layout.cshtml主页中有两个meta标签,现在我想在someone.cshtml View 页面中添加meta标签。

我也尝试使用此代码

放入_layout.cshtml主页@RenderSection("metatags",false);
放入@section metatags { <meta ... /> }之类的someone.cshtml

但没有成功。

并尝试添加meta标签jquery,但效果不佳。

最佳答案

它应该工作。

这是我的母版页_Layout.cshtml

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
@RenderSection("metatags", false)
<title>My ASP.NET Application</title>
</head>
<body>
@RenderBody()
</body>
</html>

这是 index.cshtml文件
@section metatags
{
<meta name="test" content="test"/>
<meta name="test2" content="test"/>
}

<div>Page content</div>

结果
<html>
<head>
<meta charset="utf-8">

<meta name="test" content="test">
<meta name="test2" content="test">

<title>My ASP.NET Application</title>
</head>
<body>

<div>Page content</div>

</body>
</html>

关于asp.net-mvc-5 - 使用MVC-5在“ View ”页面中添加元标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23196597/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com