布局页面头:
<head>
<link href="@Url.Content("~/Content/themes/base/Site.css")"
rel="stylesheet" type="text/css" />
</head>
Run Code Online (Sandbox Code Playgroud)
应用程序需要的View(AnotherView):
<link href="@Url.Content("~/Content/themes/base/AnotherPage.css")"
rel="stylesheet" type="text/css" />
Run Code Online (Sandbox Code Playgroud)
和AnotherView有一个局部视图(AnotherPartial)需要:
<link href="@Url.Content("~/Content/themes/base/AnotherPartial.css")"
rel="stylesheet" type="text/css" />
Run Code Online (Sandbox Code Playgroud)
问题:我们如何将这些CSS文件链接添加到Layouthead和AnotherPartial链接到Layout头?
RenderSection不是一个好主意,因为AnotherPage可以有多个Partials.添加所有CSS到头部是没用的,因为它将动态更改(它取决于Anotherpages).