我的项目结构:Mvc区域路由?
Controller
AdminController
HomeController
区加入后,我的项目structureI增加了一个管理区域项目,
Areas
Admin
Controller
SomeController
Controller
AdminController
HomeController
然后各个环节都坏了。例如
@Html.ActionLink(
"go to some action",
"SomeAction",
"Admin",
new { area = "" },
null)
当我写上面的链接,它的路线我www.myDomain.com/Admin/SomeAction
,但是这方面的行动,我想路由到AdminController行动。
我该怎么做?我应该改变区域还是控制器名称?
更新
上面的链接输出:
domain/Admin/SomeAction
// I expect that is AdminController/SomeAction
// but not. There is SomeAction in my admin controller
// I get this error "The resource cannot be found."
// because it looks my expected, but it works unexpected
// it tries to call AdminArea/SomeController/SomeAction
更新2
例如:
@Html.ActionLink(
"go to some action",
"SomeAnotherAction",
"Admin",
new { area = "" },
null)
上面的链接我没有得到任何电子邮件恐怖,因为我在我的地区有一些其他行为。
区registeration
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
谢谢...
您必须将其路由到具有SomeAction的控制器。现在你正在从AdminController调用SomeAction ActionResult。你想从AreaController调用SomeAction。或者我错过了什么? – William 2013-03-22 13:35:17
已编辑。我也很难解释。总结,我想调用项目主控制器的操作,但它调用区域控制器的操作。链接看起来是正确的,但它的工作不正确。 – 2013-03-22 13:45:46