我正在使用Areas开发ASP.NET MVC。我有三个区域。但是,默认路由不是区域。运行应用程序时,出现此错误:
路线如下所示:
RouteConfig
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 },
namespaces: new string[] { "SmartSIMS.Web.Controllers" }
);
}
区域是:
管理
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: "Administration_default",
url: "Administration/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "SmartSIMS.Web.Areas.Administration.Controllers" });
}
学生
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: "Students_default",
url: "Students/{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "SmartSIMS.Web.Areas.Students.Controllers" });
}
老师
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: "Teachers_default",
url: "Teachers/{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "SmartSIMS.Web.Areas.Teachers.Controllers" });
}
如何解决此错误?请协助。
答案 0 :(得分:0)
问题已解决。我将web.config中的RouteDebugger设置为false。非常感谢