zoukankan      html  css  js  c++  java
  • System.InvalidOperationException: 找到多个与名为“Home”的控制器匹配的类型。

    一,当项目中存在多个网站报错,而不是新增Area出现这个错误时。应该在RouteConfig这样改:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;
    
    namespace Houtai.Web.Mobile
    {
        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[] { "Houtai.Web.Mobile.Controllers" }
                );
            }
        }
    }

    二,若是添加Area,造成的错误,则

     public class RouteConfig
        {
            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 } // 参数默认值  
                    ,  new string[] { "Houtai.Web.Mobile.Controllers" }
                ); 
                  
            }
        }
  • 相关阅读:
    git之clone
    gulp之sass 监听文件,自动编译
    cat命令
    centos安装yum源
    centos下wget: command not found的解决方法
    centos安装
    为什么很多公司招聘前端开发要求有 Linux / Unix 下的开发经验?
    ASP.NET MVC HtmlHelper用法集锦
    Html.Listbox的用法(实例)
    JSON入门实例
  • 原文地址:https://www.cnblogs.com/May-day/p/6163984.html
Copyright © 2011-2022 走看看