I am trying to create an ASP.NET MVC module using MEF. So far, I have no problem using MEF without MVC, when it comes to exporting controllers, I have some difficulties.
I used this approach as an example http://kennytordeur.blogspot.de/2012/08/mef-in-aspnet-mvc-4-and-webapi.html I made this more complicated by introducing an external dll containing the controller. But if I follow Kenny's idea, then I need to have a common interface (for example, IMyTest in his example), however, since I plan to have several controllers, this will mean that I will need too many interfaces. And in the end, it looks like I'm reusing internal controller methods, not whole controllers.
I found a question here How to integrate MEF with ASP.NET MVC 4 and ASP.NET Web API , which contains some code examples, where I see a similar picture - _contactRepository of the IContactRepository interface is imported and then reused inside the view.
That is why my question is: is it normal to export the entire controller without using interfaces? And how to do it?
I found that the connection between MEF and ASP.NET is rather confusing, at first it suggests that there are several examples on the Internet, but when I look deeper, most of them are outdated and not practical or too primitive to see how this can be applied to larger projects.
Thank!
c # asp.net-mvc mef
Anelook Jul 10 '13 at 19:23 2013-07-10 19:23
source share