zoukankan      html  css  js  c++  java
  • mvc area出现“找到多个与名为“Home”的控制器匹配的类型”错误的解决方法

    出现该问题的原因是在默认的Golbal.asax.cs文件中已经注册了默认路由

        public class MvcApplication : System.Web.HttpApplication
        {
            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 } // 参数默认值
                //);

                routes.MapRoute(
                      "Member",
                      "Member/{action}/{page}",
                      new { controller = "MemberCenter", action = "List" },
                      new { action = @"Index|List|Detail", page = @"d+" }
                    );

                routes.MapRoute(
                      "Default",
                      "{controller}/{action}/{id}",
                      new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                      new string[] { "MvcStudyDemo.Controllers" }
                      );

            }

    而在AREAS中有注册了一个同名的Controller

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

    解决方法就是在每个注册Router的时候加上命名空间即可。

  • 相关阅读:
    RNN-2-前向传播、BPTT反向传播
    RNN-1-参数共享、网络的展开、常见应用
    被围绕的区域
    语言模型的评价方法
    个性化推荐系统
    推荐系统-CTR-Wide&Deep
    推荐系统-CTR-总结
    推荐系统-CTR-PNN
    Local variable flag defined in an enclosing scope must be final or effective
    2.两数相加
  • 原文地址:https://www.cnblogs.com/Alex80/p/7743564.html
Copyright © 2011-2022 走看看