【发布时间】:2011-04-11 16:39:57
【问题描述】:
有以下布局和视图:
_GlobalLayout.cshtml
_SubLoyout.cshtml
SomePage.cshtml
在 _GlobalLayout.cshtml 中我想获取所有使用的布局和当前视图名称的列表。
例如,在_GlobalLayout.cshtml中:
<html>
<head>
@Html.Some_method_that_will_know_about_used_layouts_and_view();
</head>
<body>
@RenderBody();
</body>
</html>
Some_method_that_will_know_about_used_layouts_and_view 将使用有关已使用布局和已使用视图的信息返回一些内容。
我该如何实现这个方法?
【问题讨论】:
-
在方法中我想得到一个类似的列表:
-
_GlobalLayout.cshtml _SubLoyout.cshtml SomePage.cshtml
-
不幸(也令人惊讶),如果没有反思,这似乎是不可能的。
标签: asp.net-mvc razor html-helper webpage