MVC, Get MasterPage path from inside a view

余生颓废 提交于 2020-01-24 00:58:06

问题


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.

so how do I get it?


回答1:


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 ) %>


来源:https://stackoverflow.com/questions/635941/mvc-get-masterpage-path-from-inside-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!