找到多个与名为“Home”的控制器匹配的类型,如果为此请求(“{controller}/{action}/{id}”)提供服务的路由没有指定命名空间来搜索匹配此请求的...

参考文章:

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

 

转载于:https://www.cnblogs.com/dansediao/p/8611525.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值