开发者

Nhibernate (Fluent), Ninject.Mvc3, and Web Activator

I am working on an ASP .NET Mvc 3 App and have installed Ninject.Mvc3 using Nuget. I now have the App_Start folder and then ninject class. I have seen plenty of examples on how to configure NHibernate in the Global.asax file. So how do I configure the session before handing it Ninject if I am开发者_JAVA百科 using the Web Activator class? Do I just do it like normal in the global.asax?,


Bob Cravens has a nice series of posts on how to do this:

Using the Repository Pattern with MVC and NHibernate

http://blog.bobcravens.com/2010/06/the-repository-pattern-with-linq-to-fluent-nhibernate-and-mysql/

Using an IoC container (like Ninject) with a NHibernate inside ASP.NET MVC

http://blog.bobcravens.com/2010/07/using-nhibernate-in-asp-net-mvc/

Any responsible web developer knows that managing / disposing of objects and resources is critical to good web application development. Please make sure and read this bit too :-)

http://blog.bobcravens.com/2010/11/using-ninject-to-manage-critical-resources/


I don't know which example you are refering to. But for most of them you can do it the same way.


Now, in App_Start folder you have a file called NinjectMVC.cs, there is a method:

    private static void RegisterServices(IKernel kernel)
    {
    }     

You have to register all your services there, just the same way you did in global.ascx before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜