Jamie
Jamie

Reputation: 3372

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 using the Web Activator class? Do I just do it like normal in the global.asax?,

Upvotes: 1

Views: 2307

Answers (3)

Alexander Beletsky
Alexander Beletsky

Reputation: 19821

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.

Upvotes: 0

Anuj
Anuj

Reputation: 3134

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/

Upvotes: 3

Remo Gloor
Remo Gloor

Reputation: 32725

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

Upvotes: 0

Related Questions