为什么 @Html.ActionLink("Home", "Index", "home") 会生成 Home
当我使用 Html.ActionLink 时,我发现 @Html.ActionLink("Home", "Index", "home")
生成此字符串 Home
,那么为什么地址\home\index
变成了\
,我发现这和web.conf中设置的默认路由有关。我查看了 mvc 3 源代码,但找不到答案。谁能帮助我?谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是由于默认路由造成的。如果您不指定默认操作和控制器,它将生成
/home/index
作为 url。That's due to the default route. If you don't specify default action and controller it will generate
/home/index
as url.路由是双向的:
- in:它将传入的 url 转换为控制器/操作/参数
- out:它将控制器/动作/参数转换为url
routing is bidirectional:
- in: it converts incoming urls into controller/actions/parameters
- out: it converts controller/actions/parameters into urls