How to register Controller in MVC3?
I have 2 solutions:
-
MvcApplication (MVC 3 Web Application) with file ‘HomeController.cs’
-
CustomController (Class library) with file ‘CustomController.cs’
If i Build ‘CustomController’ solution and Add reference in MvcApplication solution to this, i can simple use CustomController in application. But how i can do it without ‘Add reference’ action, just with Assembly.LoadFrom(PathToDll) e.t.c.?
You could use MEF for that.
See a good article
http://blog.maartenballiauw.be/post/2009/04/21/ASPNET-MVC-and-the-Managed-Extensibility-Framework-(MEF).aspx
This section in your global.asax, register the new controller fac and set the “Plugins” folder for MEF load their libraries. Plugins folder is in your asp.net app root folder.