【发布时间】:2011-10-13 12:33:33
【问题描述】:
我有一个叫做组织的区域。在这个区域中,我有一个带有 Url.Action 链接的视图。
默认情况下,如果我只是传递动作名称,它会在组织区域中调用当前控制器中的动作。
我在控制器文件夹中有一个控制器(不在一个区域中),我想在该控制器中调用一个动作。
基本上,任何区域都可以调用此操作。实现这一目标的最佳方法是什么?
如果这是完全错误的解决方法,那么我愿意接受建议。
谢谢,
编辑 - 这是路线
全球.asax
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Columns",
"Columns/Columns/{ID}/{idList}",
new { controller = "Columns", action = "UserColumnList" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "Login", id = UrlParameter.Optional } // Parameter defaults
);
}
OrganisationsAreaRegistration.cs
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Organisations_view",
"Organisations/{id}/View",
new { controller = "Manage", action = "View" }
);
context.MapRoute(
"Organisations_general",
"Organisations/{id}/General",
new { controller = "Manage", action = "General" }
);
context.MapRoute(
"Organisations_addressbook",
"Organisations/{id}/AddressBook",
new { controller = "Manage", action = "AddressBook" }
);
context.MapRoute(
"Organisations_departments",
"Organisations/{id}/Departments",
new { controller = "Manage", action = "Departments" }
);
context.MapRoute(
"Organisations_people",
"Organisations/{id}/People",
new { controller = "Manage", action = "People" }
);
context.MapRoute(
"Organisations_events",
"Organisations/{id}/Events",
new { controller = "Manage", action = "Events" }
);
context.MapRoute(
"Organisations_journal",
"Organisations/{id}/Journal",
new { controller = "Manage", action = "Journal" }
);
context.MapRoute(
"Organisations_tasks",
"Organisations/{id}/Tasks",
new { controller = "Manage", action = "Tasks" }
);
context.MapRoute(
"Organisations_edit",
"Organisations/{id}/Edit",
new { controller = "Manage", action = "Edit" }
);
context.MapRoute(
"Organisations_journalnew",
"Organisations/{id}/{action}",
new { controller = "Manage" }
);
context.MapRoute(
"Organisations_recent",
"Organisations/{action}",
new { controller = "Manage", action = "Index" }
);
context.MapRoute(
"Organisations_default",
"Organisations/{controller}/{action}/{id}",
new { controller = "Manage", action = "Index", id = UrlParameter.Optional }
);
}
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-routing