The layout page could not be found

asp.net-mvc-4

Solution

Make sure that in your `~/Views/_ViewStart.cshtml` file you have set the correct path:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Also if in your views you are overriding the layout ensure that the proper path is specifid for this layout. And in addition to that there could be some server side code which is setting the layout (such as custom action filters, or the `ViewResult` overload which allows to specify a layout, ...).

UPDATE:

You seem to have set the Layout like this:

@{ 
    ViewBag.Title = "title"; 
    Layout = "_Layout"; 
} 

You need to specify the location to the layout as absolute path:

@{ 
    ViewBag.Title = "title"; 
    Layout = "~/Views/Shared/_Layout.cshtml";
} 

But an even better way is to get rid of this Layout setting in your `Index` view:

@{ 
    ViewBag.Title = "title"; 
}

Now the value from your `_ViewStart.cshtml` will be used.

Problem

I get the error: The layout page "_Layout" could not be found at the following path: "~/Views/Home/_Layout". But layout page is at this path: "~/Views/Shared/_Layout" What can it be for problem? I just started the project and it look like this: Controller: ``` namespace Testing.Controllers { public class HomeController : Controller { // // GET: /Home/ public ActionResult Index() { return View(); } } } ``` Index view: ``` @model dynamic @{ ViewBag.Title = "title"; Layout = "_Layout"; } <h2>title</h2> ``` _ViewStart.cshtml: ``` @{ Layout = "~/Views/Shared/_Layout.cshtml"; } ``` Solution Explorer:

Original source