2

I met this first time in MVC. I have area "Administation" and controller in there "News" with action "List".

In debug i got breakpoint at

public ActionResult List()
{
    return View(); // Breakpoint
}

and i get there

but engine cannot find View "List"

I got error:

The view 'List' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/News/List.cshtml
~/Views/News/List.vbhtml
~/Views/Shared/List.cshtml
~/Views/Shared/List.vbhtml

View exits in location Areas/Administation/News/List.cshtml

Why Razor don't paste Area name into view view location ?

UPDATE:

I found solution: ASP.NET MVC Default routes accessible via area routes

Route route = Routes.MapRoute(name, url, defaults, constraints, namespaces);
route.DataTokens["area"] = AreaName;
Community
  • 1
  • 1
David Horák
  • 5,535
  • 10
  • 53
  • 77

1 Answers1

0

ASP.NET MVC expects that you have a matching view for the corresponding action when you call the View() method in the controller. So basically its telling you that you have to have a file called List.cshtml (or List.vbhtml) on the Views/Shared or Views/News/ folder of your project . (Your controller is called NewsController and by convention the view is searched on the name You can go to http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet-mvc-3 to see how this works.

Areas are an MVC feature to organize the code on your application, but you are probably missing some configuration for them. Read this for more information.

Luiso
  • 4,173
  • 2
  • 37
  • 60
Javier
  • 244
  • 1
  • 11