0
  • WebForms 4.61
  • IoC is done using Castle Windsor

I have a legacy WebForms application that I am working on adding IoC to. I implemented constructor and property injection for Page controls as described here which basically uses a HttpModule to perform the IoC for Page.

I now want to do the same thing for any UserControls. However there does not appear to be a hook I can use to intercede the IoC for the user control via the page life cycle or elsewhere?

I don't want to follow the approach described in this SO post which advocates a super user control base class that has all the possible interfaces in it.

So any ideas on how I add IoC (property and constructor) to System.Web.UI.UserControl?

Community
  • 1
  • 1
TheEdge
  • 9,291
  • 15
  • 67
  • 135
  • Who instantiates the UserControl? Looks like you need a factory in which you can inject your stuff. Castle has the option for property injection too if UserControl and the like does not provide what you need. – Ognyan Dimitrov May 19 '17 at 06:24
  • User control is instantiated via the usual page life cycle. – TheEdge May 22 '17 at 02:15

0 Answers0