views:

138

answers:

1
+2  Q: 

IoC in MVP Asp.NET

Hello, Guys.

I'm developing a application using MVP and I have a question about How inject my dependencis in my presenters class. Because my presente receve too an instance of the my view. I thought of create a viewbase and inside it I create my dependencies instances and inject it in my presenter instance. Could also have a HttpModule that intercept the calls to page and then I could inject my dependencies. I have some ideas but none I can inject my view in constructor only I can inject my view in mey presente by property. Someone have any ideas how do you do to inject my dependencies and my view in constructor of the presenter?

+2  A: 

To implement MVP inside of webforms is a little less perfect than MVC, mostly from the fact you cannot have a custom build factory for your page which means at some level you need to couple your page to the IOC framework, generally at a basepage level.

I wrote a blog on achieving this. Creating a generic Model-View-Presenter framework I've expanded upon this to allow me to implement many views and have a single presenter mediate many views but haven't had the time to blog about that. That's more of an advanced usage anyway, my source here should get you up and running easily. My post specifically references StructureMap 2.5.3 but it can be easily adapted to suit any IOC framework that supports the "BuildUp" type of functionality.

Chris Marisic
I'm using asp.net webforms MVP pattern I'm not using asp.net MVC.
Diego Dias
My mistake, I've changed my answer for webforms.
Chris Marisic