Home-6ren"> Home-当我使用 Html.ActionLink 时,我发现 @Html.ActionLink("Home", "Index", "home")生成此字符串 Home ,那么为什么地址是\home\index-6ren">
gpt4 book ai didi

asp.net-mvc-3 - 为什么 @Html.ActionLink ("Home", "Index", "home") 生成 Home

转载 作者:行者123 更新时间:2023-12-05 00:01:34 26 4
gpt4 key购买 nike

当我使用 Html.ActionLink 时,我发现 @Html.ActionLink("Home", "Index", "home")生成此字符串 <a href="\">Home</a> ,那么为什么地址是\home\index变成 \ , 我发现这与 web.conf 中设置的默认路由有关。我已查看 mvc 3 源代码,但找不到答案。谁能帮我?谢谢。

最佳答案

这是由于默认路由。如果您不指定默认操作和 Controller ,它将生成 /home/index作为网址。

routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { id = UrlParameter.Optional }
);

关于asp.net-mvc-3 - 为什么 @Html.ActionLink ("Home", "Index", "home") 生成 <a href ="\">Home</a>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9079774/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com