Asp.net-mvc – The view ‘Index’ or its master was not found.

asp.net-mvcasp.net-mvc-areasasp.net-mvc-routing

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.

Best Answer

What you need to do is set a token to your area name:

for instance:

context.MapRoute(
        "SomeArea_default",
        "SomeArea/{controller}/{action}/{id}",
        new { controller = "SomeController", action = "Index", id = UrlParameter.Optional }
    ).DataTokens.Add("area", "YOURAREANAME");