开发者

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:

  1. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part One
  2. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Two
  3. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Three
  4. MVC3 and MEF
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜