我正在使用 ASP.NET MVC 4 开发一个 Web 应用程序,我想按以下方式组织我的控制器和视图:
/Controller
/Admin
/LessonController.cs
/ExerciseController.cs
HomeController.cs
/Views
/Admin
/Lesson
/Index.cshtml
/Home
/Index.cshtml
我尝试了以下代码来注册路由,但它不起作用:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Admin",
url: "Admin/{controller}/action/{id}",
defaults: new { controller = "Lesson", action = "Index", id = UrlParameter.Optional }
);
}
你有什么建议吗?