I knew that I should address the popular MVC model for ASP.Net as soon as I had finished my post on Unity dependency injection for ASP.Net. A different implementation for Unity injection is required here as the MCV model has a different method of processing ASP.Net pages.
Like the posts for Unity injection with WCF and ASP.Net, there are similar implementations already published on the internet to support MVC. The main issues I have with the examples posted elsewhere are that:
- global.asax application events are used which are not easily portable between projects
- there is no support for teardown operations of the controllers created via Unity (especially important when Unity creates disposable build tree hierarchies)