The layout page could not be found

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.


I had this same problem appear once i had deployed my service, but could not replicate locally. For me the issue was that the View had None set for its build action. So the error was correct in that the file did not exist on the server, despite it existing in the repository.

Solution to fix this:

  1. Right click on missing view and open Properties View Properties
  2. Ensure Build Action is set to Content
  3. Update csproj file to match new Build Action. .csproj file