简体   繁体   English

从ASP MVC中的区域控制器链接到根控制器

[英]Link to a root controller from area controller in 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"}); %>

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. 我在根控制器集合中的一个名为Admin的文件夹中有一个名为Page控制器。 I can reach this controller by typing \\Admin\\Page. 我可以通过键入\\ 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. 我希望我可以在我的视图中使用此语法来解决“Admin”路由,但这不起作用。 Any ideas on how to fix it? 关于如何修复它的任何想法?

<% Html.RenderAction("Action", "Controller", new { area = "" }); %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM