: The layout page "~/Views/Shared/_Layout.cshtml" could not be found 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
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
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
Thanks
More posts by @Frith620
3 Comments
Sorted by latest first Latest Oldest Best
In Solution Explorer, right click on the Shared folder, then Publish Shared.
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
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:
duplicate the layout and rename it Layout2
change its call in the ViewStart.cshtml so the right layout is called per page
Go to Azure or whoever is your server and delete everything.
recreate your directory
Go back to VS and clean, build, and publish
And you should be good to go
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.