【发布时间】:2012-05-14 09:26:00
【问题描述】:
我在一个 mvc4 应用程序中有 2 个区域,并且我已经为每个区域注册了命名空间。
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Intergration_default",
"Intergration/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
constraints: null,
namespaces: new[] { "WebApplication.Areas.Intergration.Controllers" }
);
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Vend_default",
"Vend/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional},
constraints: null,
namespaces: new[] { "WebApplication.Areas.MyController.Controllers" }
);
我可以访问 Intergration/MyController 但是当我尝试访问 MyController 时出现错误
找到与名为“mycontroller”的控制器匹配的多种类型。如果为该请求提供服务的路由 ('{controller}/{action}/{id}') 未指定命名空间来搜索与请求匹配的控制器,则可能会发生这种情况。如果是这种情况,请通过调用带有“namespaces”参数的“MapRoute”方法的重载来注册此路由。
我做错了什么?我需要在 global.asax 中做一些额外的事情吗
【问题讨论】:
标签: asp.net-mvc