I have a following project structure:

_ViewStart.cshtml:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
_Red.cshtml:
@{
ViewBag.Title = "Red";
Layout = "~/Views/Shared/_Layout.cshtml";
}
_Blue.cshtml does not have a Layout specified explicitly.
Now if a try to render Index.cshtml using _Red.cshtml layout, _Layout.cshtml is also applied hierarchically. So basically we have a nested templates chain _Layout->Red->Our page
But if I try to render Index.cshtml using _Blue.cshtml, _Layout.cshtml is not applied.
I was expecting that _Layout.cshtml would be applied to _Blue.cshtml by convention using _viewstart. Instead I get Index.cshtml page with only _Blue.cshtml template being applied.
Am I wrong in my assumptions?
Thanks in advance!
UPDATE:
Controller method:
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View("Index");
}
So, I am returning ViewResult, not PartialViewResult 😉
Yes, you are wrong in your assumption. If a layout is specified (_Blue.cshtml), the layout in _Viewstart will NOT be applied. _Viewstart is for your default layout so you don’t have to specify it on every page.