我有一个涉及多个领域的MVC5项目。我有一个默认区域(名为Default),其中有一个默认控制器(名为DefaultController)。这可以在站点路线上访问。
[RouteArea]
public class DefaultController : Controller
{
[Route]
public ActionResult Index()
{
return View("Index");
}
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.LowercaseUrls = true;
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "MyProject.Areas.Default.Controllers" }
);
}
Run Code Online (Sandbox Code Playgroud)
控制器已正确加载,但是Areas/Default/Views/Default/Index.cshtml找不到视图(位于)。为什么MVC找不到正确的位置?
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations …Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc asp.net-mvc-routing attributerouting asp.net-mvc-5