ASP.NET MVC URL Routing with Multiple Route Values

后端 未结 3 970
栀梦
栀梦 2020-12-22 19:11

I am having trouble with Html.ActionLink when I have a route that takes more than one parameter. For example, given the following routes defined in my Global.asax file:

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 19:46

    It is using the first route that is fully satisfied. Try putting your SlugsAfterId route above the Default one.

    It's basically going: "Check Default. Got an action? Yes. Got an id? Yes. Use this one and chuck any other parameters in the querystring."

    As a side note, doing that will make your Default route redundant as you provide a default value for the slug parameter.

提交回复
热议问题