Reputation: 15866
I created a mvc4 web app. with razor view engine. There are Layout page and content pages(Home, Contact, About, etc.) you know. But there is no reference to layout from content pages.
Should do not content pages include this:
Layout = "~/Views/Shared/_Layout.cshtml";
In content pages this code is missing.And they works. How does it do this without layout reference?
Upvotes: 5
Views: 7256
Reputation: 1715
It's because partial views are included into a 'non-partial' page, which does have a layout defined.. So they make use of that and just become a part of that page
EDIT
I'm sorry for the late reply, I just checked it out and it appears to be cause of the _ViewStart.cshtml page, this is a page that runs before any view is rendered, read more here:
weblogs.asp.net/gunnarpeipman/archive/2010/10/10/…
Upvotes: 4
Reputation: 143
thats your masterpage if you want a partial view
@Html.Partial("partialviewname". "controller")
and the partial view doesnt use the masterpage since it is inserted to a place you desire
Upvotes: 0