参考文章:

        http://blog.csdn.net/chengmodelong/article/details/41890229

  https://www.cnblogs.com/zgqys1980/archive/2012/08/22/2650816.html

 

遇到这种情况是因为,出现该问题的原因是在默认的Golbal.asax.cs文件中已经注册了默认路由,而在AREAS中又注册了一个同名的Controller,也就是说areas中的Controller和最外层的Controller中有重名的

解决方案:

  1:Area下的XXXAreaRegistration 添加:new string[] { "areas中重名Controller的命名空间" }

  2:RouteConfig 下添加 namespaces: new string[] { "最外层中重名Controller的命名空间" }

 

例如:

   
context.MapRoute(
                "CPA_default",
                "CPA/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
                new string[] { "Exam.Web.Admin.Areas.CPA.Controllers" }
            );

 

routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional },
                namespaces: new string[] { "Exam.Web.Admin.Controllers" }
            );

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-10-26
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
猜你喜欢
  • 2021-06-30
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案