T4MVC 导致 URL 不正确
在我的新 MVC Razor 项目上使用 T4MVC,我将有一个像这样的操作链接
@Html.ActionLink(ViewRes.SharedStrings.HomeLink, MVC.Home.Views.Index, null, new { rel = "dropmenu7" })
,所以我期望像这样的 url http://localhost:52122/Home/Index
但我得到的是 http://localhost:52122/Home/~/Views/Home/Index.cshtml
查看 t4mvc 模板文件,我看到“~/Views/Home/Index.cshtml”来自哪里,但我不想碰它,因为它是这样制作的,我想我不应该这样做改变那里的任何东西。
问一个朋友,他说我应该使用 RouteLink 而不是 ActionLink,因为我有时会去控制器之外的位置。但是,当我这样做时,我得到:“在路线集合中找不到名为“~/Views/Home/Index.cshtml”的路线。”当我尝试运行该应用程序时。
我想我还应该注意到我正在使用的链接位于 _Layout.cshtml
我做错了什么?
Using T4MVC on my new MVC Razor Project and I will have an action link like so
@Html.ActionLink(ViewRes.SharedStrings.HomeLink, MVC.Home.Views.Index, null, new { rel = "dropmenu7" })
so i would expect a url like
http://localhost:52122/Home/Index
but what i am getting is
http://localhost:52122/Home/~/Views/Home/Index.cshtml
looking into the t4mvc template file, i see where the "~/Views/Home/Index.cshtml" is coming from but I dont wanna touch it because it was made that way and i would guess i shouldnt have to change anything there.
Asking a friend, he says that i should use RouteLink instead of ActionLink because i am sometimes going to locations outside of the controller. However when i do that, i get: "A route named '~/Views/Home/Index.cshtml' could not be found in the route collection." when i try to run the app.
I guess i should also note that the links i am using are in the _Layout.cshtml
What am i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 'MVC.Home.Views.Index' 更改为 'MVC.Home.Index()':
You need to change 'MVC.Home.Views.Index' to 'MVC.Home.Index()':