How to use Dependency Injection with ASP.NET Web Forms
I am trying to work out a way to use dependency injection with ASP.NET Web Forms controls.
I am trying to work out a way to use dependency injection with ASP.NET Web Forms controls.
I am trying to wire up dependency injection with Windsor to standard asp.net web forms. I think I have achieved this using a HttpModule and a CustomAttribute (code shown below), although the solution seems a little clunky and was wondering if there is a better supported solution out of the box with Windsor?
I have registered a custom MembershipProvider class in my Web.Config file. I’m using Inversion Of Control using Castle Windsor and I have registered my custom MembershipProvider class as transient (because it’s using a service that’s transient as well).
I’m still pretty new to using Autofac and one thing I miss in the documentation and examples is how to make it easy to get to the configured container from different places in a web application.
I am new to IoC and am using Autofac in my current project.
My goal is to modify asp.net mvc’s controller registery so that I can create controllers and views in a separate (child) assembly, and just copy the View files and the DLLs to the host MVC application and the new controllers are effectively “Plugged In” to the host app.
So I have a legacy webforms site and am working on making it easier to maintain. Chucking it away and rewriting it isn’t an option.
I have a custom HTTP Module. I would like to inject the logger using my IoC framework, so I can log errors in the module. However, of course I don’t get a constructor, so can’t inject it into that. What’s the best way to go about this?
I have been looking into the Castle project and specifically Windsor. I have been so impressed with what is possible with this technology and the benefits of having a such a loosely coupled system are definitely apparent. The only thing I am unsure of is if using this method has any downsides, specifically in asp.net? for example performance hits, etc.
We are using classes inheriting from Registry to configure our StructureMap container in our ASP.NET MVC 4 application startup.