title: Doing Inversion Of Control with webforms aspx user control
body: <ul>
  <li>WebForms 4.61</li>
  <li>IoC is done using Castle Windsor</li>
  </ul>
  
  <p>I have a legacy WebForms application that I am working on adding IoC to. I implemented constructor and property injection for Page controls as <a href="https://blogs.msdn.microsoft.com/webdev/2016/10/19/modern-asp-net-web-forms-development-dependency-injection/" rel="nofollow noreferrer">described here</a> which basically uses a HttpModule to perform the IoC for Page.</p>
  
  <p>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?</p>
  
  <p>I don't want to follow the approach described in this <a href="https://stackoverflow.com/questions/27507377/ioc-and-webforms-how-to-inject-properties-in-user-controls">SO</a> post which advocates a super user control base class that has all the possible interfaces in it.</p>
  
  <p>So any ideas on how I add IoC (property and constructor) to System.Web.UI.UserControl?</p>