从ASP MVC中的区域控制器链接到根控制器 [英] Link to a root controller from area controller in ASP MVC
本文介绍了从ASP MVC中的区域控制器链接到根控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从一个区域链接到我的一个根控制器?
How can I link to one of my root controllers from one of my areas?
<% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %>
这给了我一个错误:
路由表中没有路由与提供的值匹配.
No route in the route table matches the supplied values.
我的根控制器集合中的名为Admin
的文件夹中有一个名为Page
的控制器.
我可以通过键入\ Admin \ Page来访问此控制器.
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?
推荐答案
<% Html.RenderAction("Action", "Controller", new { area = "" }); %>
这篇关于从ASP MVC中的区域控制器链接到根控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文