我的项目中有两个领域:
Areas | Admin
Areas | FrontEnd
我想要的是当我访问该站点时,默认路由应该从该FrontEnd
区域加载控制器/视图/模型。拥有管理面板是正常的,Url/Admin
但我宁愿不必强制Url/FrontEnd
(或其他一些变化)。基本上我不想在根级别使用 Controller / Model / View 文件夹。
我不确定如何更改代码以允许这样做,甚至这是一种可取的方法。有人可以提供一些指导吗?
是)我有的:
routes.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new {
area = "Admin",
controller = "Home",
action = "Index",
id = UrlParameter.Optional
},
namespaces: new[] { "WebsiteEngine.Areas.Admin.Controllers" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {
area = "FrontEnd",
controller = "Home",
action = "Index",
id = UrlParameter.Optional
},
namespaces: new[] { "WebsiteEngine.Areas.FrontEnd.Controllers" }
);
但是,这会产生错误:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
我确实在该地区有可用的视图,但这看起来不像它在那里。