MVC,从视图中获取MasterPage路径

时间:2009-03-11 19:13:55

标签: asp.net-mvc master-pages

如何从视图中获取母版页的路径,我认为

((WebFormView)Html.ViewContext.View).MasterPath

可以做到这一点,但不幸的是,它总是空着的。

所以我怎么得到它?

1 个答案:

答案 0 :(得分:1)

我不确定你需要什么,但是View应该有一个MasterPageFile属性,它包含MasterPage的相对路径。如果需要物理位置,可以使用MapPath。

<%= this.MasterPageFile %>

<%= MapPath( this.MasterPageFile ) %>