The view 'Index' or its master was not found.

Viewed 107950
The view 'Index' or its master was not found. The following locations were searched:
~/Views/ControllerName/Index.aspx
~/Views/ControllerName/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx

I got this error when using ASP.Net mvc area. The area controller action are invoked, but it seems to look for the view in the 'base' project views instead of in the area views folder.

17 Answers

The problem was that I used MvcRoute.MappUrl from MvcContrib to route the context.Routes.

It seems that MvcContrib routing mapper was uncomfortable with area routing.

You most likely did not create your own view engine.
The default view engine looks for the views in ~/Views/[Controller]/ and ~/Views/Shared/.

You need to create your own view engine to make sure the views are searched in area views folder.

Take a look this post by Phil Haack.

Add the following code in the Application_Start() method inside your project:

ViewEngines.Engines.Add(new RazorViewEngine());

I added viewlocationformat to RazorViewEngine and worked for me.

ViewLocationFormats = new[] {
            "~/Views/{1}/{0}.cshtml",
            "~/Views/Shared/{0}.cshtml",
            "~/Areas/Admin/Views/{1}/{0}.cshtml",
            "~/Areas/Admin/Views/Shared/{0}.cshtml"
        };
Related