从 ASP MVC 中的区域控制器链接到根控制器
如何从我的区域之一链接到我的根控制器之一?
<% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %>
这给了我一个错误:
路由表中没有路由与提供的值匹配。
我的根控制器集合中名为 Admin
的文件夹中有一个名为 Page
的控制器。 我可以通过输入 \Admin\Page 来访问此控制器。
这就是我注册路由的方式:
routes.MapRoute(
"Admin",
"Admin/{controller}/{action}/{id}",
new { controller = "Admin", action = "Index", id = "" }
);
在我看来,我希望可以使用此语法来寻址“Admin”路由,但这不起作用。关于如何修复它有什么想法吗?
How can I link to one of my root controllers from one of my areas?
<% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %>
This gives me an error:
No route in the route table matches the supplied values.
I have a controller named Page
in a folder named Admin
in my root controller collection.
I can reach this controller by typing \Admin\Page.
This is how I registered the route:
routes.MapRoute(
"Admin",
"Admin/{controller}/{action}/{id}",
new { controller = "Admin", action = "Index", id = "" }
);
I was hoping I could address the "Admin" route using this syntax in my view, but that did not work. Any ideas on how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)