moi_meme
moi_meme

Reputation: 9318

MVC, Get MasterPage path from inside a view

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?

Upvotes: 0

Views: 645

Answers (1)

tvanfosson
tvanfosson

Reputation: 532485

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

Upvotes: 1

Related Questions