0

I am converting an Forms based application to add some MVC 4 View Pages.

I have been able to get pages to work but when I create a view, it never looks in my Views/Shared folder and requires me to put the shared page inside the same view folder instead of defaulting to Shared layout if not specified.

Where is the routing information precedence in MVC4 stored so I configure it to look in the shared folder first? In a slightly related question, is there any way to get the Add Contoller wizard option to show up when right clicking on the Controllers folder and the Wizard to for the scaffolding views? (See picture below of add wizard for example)

enter image description here Update: After some frustrating time I have added the file into the path desired by the error message and I still getting the error message. It seems the routing is working because when I return a string, the route finds and displays it. The problem appears to happen when I use an ActionResult and for some reason cannot find the "associated" files.

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
done_merson
  • 2,800
  • 2
  • 22
  • 30

1 Answers1

1

In your _ViewStart.cshtml file in your Views folder, you should have something like:

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

That's what tells it where to look for the layout.

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148