MVC,从视图中获取母版路径 [英] MVC, Get MasterPage path from inside a view
本文介绍了MVC,从视图中获取母版路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能从视图中获得母版的路径,我认为因子评分
How can i get the path of the MasterPage from inside a view, I tought that
((WebFormView)Html.ViewContext.View).MasterPath
会做的伎俩,但不幸的是,它总是空的。
would do the trick, but unfortunately, it's always empty.
让我怎么得到它呢?
推荐答案
我n要确定你需要的究竟是什么,但观应该包含对母版的相对路径的MasterPageFile属性。如果你需要的物理位置,你可以使用的MapPath。
I'm nto sure what you need exactly, but the View should have a MasterPageFile property that contains the relative path to the MasterPage. You can use MapPath if you need the physical location.
<%= this.MasterPageFile %>
<%= MapPath( this.MasterPageFile ) %>
这篇关于MVC,从视图中获取母版路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文