【发布时间】:2017-06-29 08:06:34
【问题描述】:
我想将区域用作单独的项目。每当我尝试导航到此链接时: http://localhost:100/module/home
我的解决方案包含两个项目:实体框架和模块
我在 entity_framework 中的 Route.config 看起来:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "User", action = "Index", id = UrlParameter.Optional },
namespaces:new string[] {"entity_framework.Controllers"}
);
}
}
我的 moduleAreaRegistration.cs :
namespace entity_framework
{
public class moduleAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "module";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"module_default",
"module/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new string[] {"entity_framework.Controllers"}
);
}
}
}
我也在项目和索引视图中的主控制器中添加了索引操作,但我陷入了这个错误。提前致谢。
【问题讨论】:
-
区域注册码被调用了吗?你有什么?主项目是否引用区域项目?
-
@DavidG 先生,我已经编辑并显示了我的区域注册。您能看一次吗?
-
@DavidG 先生,您能帮我解决问题吗?我被困在其中。这是我通过并尝试创建模块化项目的链接:**geekswithblogs.net/cokobware/archive/2013/01/15/…**
标签: asp.net-mvc-4 asp.net-mvc-routing asp.net-mvc-areas