c# - 从 ASP MVC 中的区域 Controller 链接到根 Controller

标签 c# asp.net-mvc asp.net-mvc-2 asp.net-mvc-routing asp.net-mvc-areas

如何从我的区域之一链接到我的根 Controller 之一?

<% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %>

这给了我一个错误:

No route in the route table matches the supplied values.

我的根 Controller 集合中名为 Admin 的文件夹中有一个名为 Page 的 Controller 。 我可以通过键入\Admin\Page 访问此 Controller 。

这是我注册路线的方式:

        routes.MapRoute(
            "Admin",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Admin", action = "Index", id = "" }
        );

我希望我可以使用我认为的这种语法来处理“Admin”路由,但这没有用。关于如何修复它的任何想法?

最佳答案

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

关于c# - 从 ASP MVC 中的区域 Controller 链接到根 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2126913/

相关文章:

C#通过smtp发送经过身份验证的邮件

c# - Microsoft Dynamics CRM SDK CRMServiceClient 连接字符串缓存错误

c# - 为什么在集合初始值设定项的末尾可以有一个逗号?

Jquery AJAX删除问题

c# - 带有加载和表单模型的 MVC View

c# - 调试 C++/Cli : <Unknown function> and no Locals

c# - 无法在 Azure C# 上创建存储帐户

c# - 在 Ninject 中查找抽象类绑定(bind)到哪个类

asp.net-mvc-2 - 将 KeyValuePair 列表绑定(bind)到复选框

jquery - MVC2 EditorFor - 使用 jQuery 添加条目