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

来源:互联网 发布:海康设备域名怎么设置 编辑:程序博客网 时间:2024/06/05 06:20

代码


/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"}
          );

原创粉丝点击