title: ASP.NET MVC 4.0 Controllers and MEF, how to bring these two together?
body: <p>I'm trying to create ASP.NET MVC module by using MEF. While I have no problems so far by using MEF without MVC, when it comes to exporting Controllers I have some difficulties. </p>
  
  <p>I used this approach as example <a href="http://kennytordeur.blogspot.de/2012/08/mef-in-aspnet-mvc-4-and-webapi.html" rel="nofollow noreferrer">http://kennytordeur.blogspot.de/2012/08/mef-in-aspnet-mvc-4-and-webapi.html</a>
  I made it more complex by introducing an external dll,  which contained a controller. But if I follow the idea of Kenny, then I need to have a common interface (like IMyTest in his example), however, as I plan to have a number of controllers, it would mean that I will need too many interfaces. And in the end, it looks like I reuse inner methods of  controllers, instead of whole controllers. </p>
  
  <p>I found a question here <a href="https://stackoverflow.com/questions/13566688/how-to-integrate-mef-with-asp-net-mvc-4-and-asp-net-web-api">How to integrate MEF with ASP.NET MVC 4 and ASP.NET Web API</a>, which contained some code examples, where I see the similar picture -  _contactRepository of an interface IContactRepository is imported and then reused inside a view.</p>
  
  <p>That is why my question is, is it normal to export the whole controller, without using interfaces? And how to do so?</p>
  
  <p>I found the connection between MEF and ASP.NET quite confusing, at first it seams that there are a number of examples in the Internet, but when I look deeper, most of them are outdated and not practical or too primitive to see how it can be applied to bigger projects.</p>
  
  <p>Thanks!</p>