代码之家  ›  专栏  ›  技术社区  ›  Cruiser KID

RouteLink问题

  •  0
  • Cruiser KID  · 技术社区  · 14 年前

                routes.MapRoute(
                "TaxReport", // Route name
                "taxes/us/{state}/{taxType}/{year}/{quarter}", // URL with parameters
                new
                {
                    controller = "TaxViewer",
                    action = "TaxReport",
                    taxType = "all-taxes",
                    year = "",
                    quarter = "Q1"
                } // Parameter defaults
            );
    

    我打电话的时候 <%= Html.RouteLink(state.State, "TaxReport", new { state = state.StateUrlCode, taxType = Model.TaxTypes.SelectedValue })%>

    我不知道为什么。当我有的时候,这条路运行得很好 "{state}/{taxType}/{year}/{quarter}" 但现在它不起作用了。

    1 回复  |  直到 14 年前
        1
  •  2
  •   Buildstarted    14 年前

    我不知道你期望什么样的产出,但你一年也过不了

    Html.RouteLink("AK", "TaxReport", new { state="AK", year=2010, taxType="all-taxes" })
    

    像这样的动作

    public ActionResult TaxReport(string taxType, int year, string quarter) {
        return View();
    }
    

    看起来很好-怎么不管用?