zoukankan      html  css  js  c++  java
  • 找到多个与名为“Home”的控制器匹配的类型的解决方案

     主地址:http://localhost:3412/Home/Index

    区域地址:http://localhost:3412/T200/Home/Index

    解决方法: 注册路由添加命名空间(namespaces)参数 (一定要是正确的)

    public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                    //这里很重要 一定要是正确的 命名空间 否则一样会报错 
                    namespaces: new string[] { "Demo.Controllers" }
                );
            }
        }
    

      

     区域配置也需要修改

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

      

  • 相关阅读:
    洛谷 P3521 [POI2011]ROT-Tree Rotations 解题报告
    洛谷 P1640 [SCOI2010]连续攻击游戏 解题报告
    vector-pop_back
    vector-push_back
    vector-push_back
    vector-max_size
    vector-max_size
    vector-insert
    vector-insert
    vector-front
  • 原文地址:https://www.cnblogs.com/LoveTX/p/7709284.html
Copyright © 2011-2022 走看看