我想在一个结合ASP.Net webforms和ASP.Net MVC的项目中使用Ninject。我使用的是Ninject 2,但是当我使用Ninject.Web.Mvc中的NinjectHttpApplication时,它会抱怨当我使用诸如PageBase之类的内容时,内核不会被创建。Ninject with ASP.Net webforms和MVC
我在Global.asax中有以下内容,我不确定要添加什么。
public class MvcApplication : Ninject.Web.Mvc.NinjectHttpApplication
{
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
RegisterAllControllersIn(Assembly.GetExecutingAssembly());
}
protected override Ninject.IKernel CreateKernel()
{
return new StandardKernel(new ServiceModule());
}
}
有人有这个工作的地方可以分享一些想法或代码吗?
感谢您的回复。我已经做了1,并试图将两个HttpApplications合并为一个。但这并不“感觉正确”。我在Ninject邮件列表中发布了一条消息,当我收到有用的回复时,会通知您。 – 2010-07-02 06:20:11