ASP.NET MVC 3 应用程序的扩展?
我需要编写一个可扩展的 ASP.NET MVC 3 应用程序,而扩展是一个具有非常特定用途的.dll
(即:论坛扩展、博客扩展、维基扩展等)。
不过,扩展程序不会有任何视图,这应该会使这个过程变得更加简单。它应该只有控制器和几个模型。
我一直在考虑使用 MVC 区域来实现这一点,并像这样加载它们:
// 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();
...
}
现在这工作得很好,但是,它看起来仍然是一种相当古老和静态的方式...... .NET 4 具有托管可扩展性框架。 MVC 3 具有依赖注入。
我读过有关便携式区域和 SharpArchitecture 的内容。我试图从源代码和文档中了解 Orchard 插件框架。但我仍然不确定我应该使用什么。
为了使我的问题更加实际 - 如何将外部项目中的控制器和模型包含到主 MVC Web 应用程序中?最好的方法是什么?我应该在这里使用依赖注入吗?
谢谢。
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 documentation. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前已经看过这个,请告诉我这些是否有帮助:
I've had a look at this previously, let me know if these help: