MVC我的url正在创建“?Length = 4”

我正在创建一个MVC4应用程序。 我有一个小问题。 我的代码是

  • @Html.ActionLink("Contract", "Contract", "Home", new { id = "lnk_contract" })
  • 我正在收集url
    http://localhost:2355/Home/Contract?Length=4

    我想要我的url
    http://localhost:2355/Home/Contract

    我的结论是

     routes.MapRoute( name: "Default", url: "{controller}/{action}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); 

    如果你有答案,请帮帮我…

    你混淆了参数。 您必须将匿名对象作为htmlAttributes参数发送。

     @Html.ActionLink("Contract", "Contract", "Home", null ,new { id = "lnk_contract" }) 

    这是此重载的MSDN页面:

    http://msdn.microsoft.com/en-us/library/dd504972(v=vs.108).aspx

    您需要添加参数

     , new {} 

    Html.ActionLink

    第一个对象用于查询字符串,第二个用于HTML参数。