views:

332

answers:

1

I have a pretty basic NHibernate setup. I am not using Castle Widnsor or anything special like that to do IoC in my code. All I want to do is set my Lifestyle to PerWebRequest, but I cannot figure out how to do this with out going back through my code and updating it to use an IoC library.

Is there any way to do this in the config file?

+1  A: 

You have to write a HttpModule that creates a session on the BeginRequest event and disposes of it in the EndRequest event.

There is an article on codeproject by Billy McCafferty. You can also take a look at Ayende Rhino.Commons stuff.

Simon Laroche