gpt4 book ai didi

asp.net-mvc - Asp.Net MVC 注入(inject)和区域

转载 作者:行者123 更新时间:2023-12-01 00:31:27 25 4
gpt4 key购买 nike

我有一个使用 Ninject 进行依赖注入(inject)的网站,我在 Bootstrapper 类中定义了路由,如下所示:

    public void RegisterRoutes()
{
Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

Routes.MapRoute(
null,
"{pageTitle}",
new { controller = "Home", action = "Page", pageTitle = "Index" }
);

Routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

}

我已经在项目中添加了一个区域,但是默认的 AdminAreaRegistration 没有注册根

    public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}

在哪里或如何使用 Ninject 注册区域?

最佳答案

源代码附带的示例项目现在有一个区域。看一看。 https://github.com/ninject/ninject.web.mvc/zipball/master

关于asp.net-mvc - Asp.Net MVC 注入(inject)和区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3931695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com