Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got this error and I can't figure out what is going on. I am positive the _layout.cshtml resides in the shared folder and for the sake of trying things out, I moved to the Home folder and it then told that the Views/Home/_Layout.cshtml couldn't be found there either. So now I'm thinking the problem is in the call for this file for some reason.

I'm not going to pretend I know ASP.NET MVC4, so please when you answer, explain it as you would to someone who is not familiar with the system at all. Believe it or not, this error came from tutorial #1 ha ha

Here's the code to show that I did code it right:

   ViewBag.Title = "Home Page";
   Layout = "~/Views/Shared/_Layout.cshtml";

And here is a picture of the location

enter image description here

p.s. I did my research, Google has nothing and there is another question here but it was asked on 2008 with MVC3 which is completely different

I am running ASP.NET MVC4 on Azure


share|improve this question

if you rename your project you can get that error. Solution is simple. Just remove tilda (~) -> /View/.... instead of ~/View..., also in your _Layout file remove tilda from all links

share|improve this answer

In case someone is interested or had the same problem. It seems this may be a problem with the server (hence, why it runs fine in localhost) :) But anyway, if it happens to you, do this:

  1. duplicate the layout and rename it Layout2
  2. change its call in the ViewStart.cshtml so the right layout is called per page
  3. Go to Azure or whoever is your server and delete everything.
  4. recreate your directory
  5. Go back to VS and clean, build, and publish

And you should be good to go

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.