ASP.NET MVC Html.ActionLink result URL - the way of encoding

痞子三分冷 提交于 2019-12-01 05:38:51

You don't show your routes, but you're almost certainly hitting different routes in this example. The argument to your action must be named the same as the token in the route in order for the generated URL to match the route token with the lambda form of ActionLink. Anything which does not match a routing token will be appended as a query string parameter, as with your second URL. Seeing the query string parameter is strong evidence that the name you passed implicitly ("property" in this case) does not match a route token. Since you get different results with the same token name, I thereby conclude you are hitting different routes. Incidentally, I recommend building links with RouteLink instead of ActionLink, so that you can be certain of which route you will match.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!