【问题标题】:Routes in MVC 3MVC 3 中的路由
【发布时间】:2013-11-05 18:59:41
【问题描述】:

有人知道 IgnoreRoute() 指令是否像 Apache 指令一样在第一个匹配的规则上触发,还是它们的行为不同?

我想将我的 elmah.axd 路由到与其他 .axd 文件不同的位置,因此我创建了 2 个 IgnoreRoute 规则,其中第一个规则将捕获 elmah.axd,第二个规则将捕获所有其他 .axd 文件。

这是我所拥有的:

  public static void RegisterRoutes(RouteCollection routes)
    {

        // AXD files
        routes.IgnoreRoute("AdminTools/elmah.axd/{*pathinfo}");
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        //Everything else
        routes.IgnoreRoute("{resource}.txt");
        routes.IgnoreRoute("favicon.ico");

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

    }

【问题讨论】:

    标签: asp.net-mvc-3 asp.net-mvc-routing


    【解决方案1】:

    检查这个article on Three common ASP.NET MVC URL routing issues

    您需要按从高到低的顺序添加它们 [路线] 具体

    【讨论】:

      猜你喜欢
      • 2011-08-30
      • 2011-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-14
      • 1970-01-01
      相关资源
      最近更新 更多