How to ignore current route values when generating links?

后端 未结 4 1003
挽巷
挽巷 2020-12-29 07:55

The question is similar to asp.net mvc Html.ActionLink() keeping route value I don't want, but with a twist that makes it more complex.

Starting from a default n

4条回答
  •  悲&欢浪女
    2020-12-29 08:44

    Because r2 does not define the id parameter to be a part of the URL? If you change it to {controller}/{action}/{id}, it will be fine. You'll see the same behaviour if you change r2 to not include action: action will then also becoe a query variable.

    The fact that you explicitly set it to "" means that routing will take it into account anyway. Just don't add id and you'll be fine when generating a link.

提交回复
热议问题