现在的位置: 首页 > 综合 > 正文

ASP.NET MVC Controller与Areas下面的Controller同名的解决办法

2013年11月15日 ⁄ 综合 ⁄ 共 578字 ⁄ 字号 评论关闭

代码

/Areas/Test/TestAreaRegistration.cs


context.MapRoute(
                
"Test_default",
                
"Test/{controller}/{action}/{id}/",
                
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                
new string[] { "Web.Areas.Test.Controllers"}
            );

//Global.asax

 routes.MapRoute(
             
"Home"// Route name
             "{controller}/{action}/{id}/"// URL with parameters
             new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                
new string[] { "Web.Controllers"}
          );

抱歉!评论已关闭.