Extensions for a ASP.NET MVC 3 Application?
I need to write an extensible ASP.NET MVC 3 application, while an extension is a .dll
with a very specific purpose (i.e: a forum extension, a blog extension, a wiki extension, etc).
An extension wouldn't have any views though, which should make this process much simpler. It should only has controllers and a few models.
I've been thinking about implementing this with MVC areas, and load them like so:
// Global.asax
public static void PreApplicationStartMethod()
{
foreach (var file in Directory.GetFiles(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions/"), "*.dll"))
{
BuildManager.AddReferencedAssembly(Assembly.LoadFile(file));
}
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
...
}
Now this worked perfectly, but still, it seems like a pretty old and static way... .NET 4 has Managed Extensibility Framework. MVC 3 has Dependency Injection.
I've read about Portable Areas and SharpArchitecture. I was trying to understand the Orchard plugin framework both from the source code and the d开发者_开发百科ocumentation. But still I'm not sure what should I use.
To make my question more practical - how would you include Controllers and Models from an external project to the main MVC web application? What is the best way to do this? Should I use Dependency Injection here?
Thanks.
I've had a look at this previously, let me know if these help:
- Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part One
- Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Two
- Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Three
- MVC3 and MEF
精彩评论