ASp.NET MVC 1.0映射到子目录的路由

时间:2010-03-01 10:07:26

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

如何设置网址/customer/export/billing到控制器Customer.ExportBilling()的路由?

当我尝试这个时:

        routes.MapRoute(
            "exportCustomerBilling", "customer/export/billing", new { controller = "Customer", action = "ExportBilling" });

我得到404,没有调用控制器方法。

使用<%= Html.RouteLink("Export customers for billing", "exportCustomerBilling", null) %>返回正确的链接,点击它会返回404。

1 个答案:

答案 0 :(得分:1)

您可能在出口结算路线上方注册了更为通用的路线。

Routing Debuggers中的一个放入您的网站,并在Global.asax中注册,它会告诉您:

  1. 路线的顺序是什么。
  2. 哪条路线与您的请求匹配。
  3. 你通常可以从那里找出你需要做的调整。