【发布时间】:2011-07-03 13:57:59
【问题描述】:
我有一个 ASP.Net MVC 3 应用程序。有 2 个区域:
- Auth - 处理所有的身份验证等
- 管理 - 物业管理领域
在管理区域中,我有一个 ManagementController 和一个 PropertyController。 ManagementController 什么都不做,它只有一个简单的 Index ActionResult 而不是返回一个视图。
PropertyController 有一个 Index ActionResult,它返回一个带有属性列表的视图,以及一个以 propertyId 作为参数的 Edit ActionResult。在 Property Index 视图中,我有一个带有属性列表的网格和一个使用以下代码编辑属性的选项:
@Html.ActionLink("Edit", "Edit","Property", new { id = item.PropertyId })
理论上这应该重定向到我的属性控制器的编辑操作结果,但是它重定向到我的管理控制器的索引操作结果。我的 ManagementAreaRegistration 文件如下所示:
context.MapRoute(null, "management", new { controller = "management", action = "Index" });
context.MapRoute(null, "management/properties", new { controller = "Property", action = "Index" });
context.MapRoute(null, "management/properties/Edit/{propertyId}", new { controller = "Property", action = "Edit" });
我的 global.asax 的 RegisterRoutes 是这样的:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
我错过了什么,为什么它会重定向到错误的控制器和操作? 提前致谢!
【问题讨论】:
标签: asp.net-mvc