找到多个与名为“Index”的控制器匹配的类型的解决方法!

 

“/”应用程序中的服务器错误。


找到多个与名为“Index”的控制器匹配的类型。如果为此请求(“{controller}/{action}/{id}”)提供服务的路由在搜索匹配此请求的控制器时没有指定命名空间,则会发生此情况。如果是这样,请通过调用含有 'namespaces' 参数的 'MapRoute' 方法的重载来注册此路由。

“Index”请求找到下列匹配的控制器:
CMS.Areas.Mana.Controllers.IndexController
CMS.Controllers.IndexController

 解决方法如下:

将APP_Start文件夹下的RouteConfig.cs 改为:

 public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new string[] { "CMS.Controllers" } //加入这个

 

 

            );
        }

 

 

将Areas文件夹下Mana文件中的ManaAreaRegistration.cs 改为

    public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Mana_default",
                "Mana/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
                new string[] { "CMS.Areas.Mana.Controllers" }//加入这个
            );
        }

 

posted @ 2013-12-02 12:16  代码沉思者  阅读(538)  评论(0编辑  收藏  举报