在Global.asax.cs里可见如下类似设置:
public
class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
// 路由忽略
routes.IgnoreRoute( " {resource}.axd/{*pathInfo} ");
routes.MapRoute(
name: " DevList ",
url: " {controller}/{action}/{id} ",
defaults: new { controller = " Data ", action = " List ", id = UrlParameter.Optional }
);
// 默认启动name为Default的路由,有多个MapRoute时,建议将Default项放在最后
routes.MapRoute(
name: " Default ",
url: " {controller}/{action}/{id} ",
defaults: new { controller = " Home ", action = " Login ", id = UrlParameter.Optional }
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}
{
public static void RegisterRoutes(RouteCollection routes)
{
// 路由忽略
routes.IgnoreRoute( " {resource}.axd/{*pathInfo} ");
routes.MapRoute(
name: " DevList ",
url: " {controller}/{action}/{id} ",
defaults: new { controller = " Data ", action = " List ", id = UrlParameter.Optional }
);
// 默认启动name为Default的路由,有多个MapRoute时,建议将Default项放在最后
routes.MapRoute(
name: " Default ",
url: " {controller}/{action}/{id} ",
defaults: new { controller = " Home ", action = " Login ", id = UrlParameter.Optional }
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}