为什么在ASP.NET MVC 3中,默认路由不适用于名为"ContentController"的控制器?

qua*_*els 5 asp.net-mvc routes asp.net-mvc-3

我有一个全新的asp.net mvc 3项目.我没有以任何方式修改路线.我有一个控制器PageController和另一个控制器调用ContentController.

当我浏览到domain.com/Page时,页面控制器上的索引操作将按预期执行并显示索引视图.

当我浏览到domain.com/Content时,我收到404错误.如果我浏览到domain.com/Content/Index,那么它可以正常工作.

如何排除这条路线的故障?

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

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        ); 
    }
Run Code Online (Sandbox Code Playgroud)

我尝试添加其他路线:

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

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        ); 
        routes.MapRoute(
             "Content", // Route name
             "Content/{action}/{id}", // URL with parameters
             new { controller = "Content", action = "Index", id = UrlParameter.Optional } // Parameter defaults
         );

    }
Run Code Online (Sandbox Code Playgroud)

但附加路线并没有改变应用程序的行为.

可能是什么导致了这个?

nat*_*lez 11

因为有一个名为content的物理文件夹.拥有与物理文件夹同名的控制器可能会对您的网站产生一些不利影响.