找到多个与名为“HOME”的控制器匹配的类型。如果为此请求(“{CONTROLLER}/{ACTION}/{ID}”)提供服务的路由在搜索匹配此请求的控制器时没有指定命名空间,则会发生此情况。如果是这样,请通过调用含有“NAMESPACES”参数的“MAPROUTE”方法的重载来注册此路由。

public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
"Default", // 路由名称
"{controller}/{action}/{id}", // 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional },// 参数默认值
new string[] { "MvcApplication1.Controllers" }
);

}

 

 

 

区域路由

 

public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new {controller="Home", action = "Index", id = UrlParameter.Optional },
new string[] { "MvcApplication1.Areas.Admin.Controllers" }
);
}

posted @ 2015-01-16 15:41  逗比浪波万  阅读(3322)  评论(0编辑  收藏  举报