MVC中的布局页_Layout.cshtml,如何以编程方式动态的向名为head的section中加内容
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
<link href="http://localhost/App_Themes/Base.css" rel="stylesheet" />
@RenderSection("head", required: true)@*View页面自定义特定js/css使用*@
</head>
<body>
@RenderBody()
<script src="http://localhost/js/base.js"></script>
@RenderSection("impJs")
@RenderSection("runJs")
</body>
</html>
就像以前传统asp.net中访问母版页那样:
this.Master.Master.FindControl("head").FindControl("head").Controls.Add(link);