我想使用 ASP.NET MVC2 实现一个基本 Web 应用程序,该应用程序将自动扫描已部署的程序集以查找某个接口的实现 - 我们将其称为 IWebModule。因此,第三方供应商应该可以实现接口以将其模块集成到应用程序中。当然,至少必须有两个程序集 - 一个用于基本 Web 应用程序,另一个用于模块。
为了让事情更清楚一些,想象一下基本应用程序有一个首选项视图,该视图在树中显示所有可用的 IWebModule 实现,并且通过单击其中一个节点,将显示模块特定的首选项视图。
第三方首选项视图、控制器和模型应在 CustomeModuleSolution 中实现,而不是在 BaseApplicationSolution 中实现。这种方法也应该适用于其他东西,如应用程序菜单、工具栏等。只需实现基本应用程序提供的接口即可增强应用程序功能 - 因此这就像使用扩展点通过实现注册的接口来向应用程序添加功能一样加载项和事件处理程序以供进一步使用。
这个问题的重点是如何在不同的解决方案中实现模型、视图和控制器(或将 Web 应用程序拆分为模块解决方案)以及如何使其一起运行。
CustomModuleSolution
|-Controllers
|-Models
|-Views
|-Preferences
|-CustomModulePreferenceView.aspx
BaseApplicationSolution
|-Controllers
|-Models
|-Views
|-Preferences
|-Preferences.aspx
如果有办法做到这一点,请告诉我。有人知道使用 WebForms 完成此任务的解决方案吗?
我感谢你的帮助!先感谢您!
I want to implement a base web application using ASP.NET MVC2 that will automatically scan the deployed assemblies for implementations of a certain interface - lets call it IWebModule. So it should be possible for third party vendors to implement the interface to integrate their module into the application. Of course there have to be two assemblies at the minimum - one for the base web application and one for the module.
To make things a bit more clear imagine that the base application has a preferences view that displays all available IWebModule implementations in a tree and by clicking on one of the nodes a module specific preferences view will be shown.
The third-party preference view, controller, and model should be implemented in the CustomeModuleSolution, not in the BaseApplicationSolution. This approach should also be useable for other things like application menus, toolbars etc. The application functionality can be enhanced by just implementing provided interfaces of the base application - so this is like using extension points to add functionality to the application by implementing interfaces which register add-ins and event handlers for further use.
The focus of this question is the how to implement the model, views and controller in different solutions (or split an web application into module solutions) and how to get it run together.
CustomModuleSolution
|-Controllers
|-Models
|-Views
|-Preferences
|-CustomModulePreferenceView.aspx
BaseApplicationSolution
|-Controllers
|-Models
|-Views
|-Preferences
|-Preferences.aspx
If there is a way to do this, please let me know. Does someone know a solution to get this done using WebForms?
I appreciate your help! Thank you in advance!
发布评论
评论(3)
这听起来很像 MvcContrib 的“nofollow">可移植区域。也许你可以看看他们做了什么。
This sounds a lot like Portable Areas from MvcContrib. Perhaps you can look at what they've done.
据我所知,MVC 2 或 3 本身不支持您所要求的内容。
人们想出了一些解决方法:
http://codeofrob.com/archive/2010/02/14/multi-tenancy-in-asp.net-mvc-controller-actions-part-i.aspx
这是一个非常好的解决方案:
http://mvcex.codeplex.com/
Google“mvc multitenancy”了解其他示例。
What you are asking for is not supported natively by MVC 2 or 3 as far as I know.
People have come up with some workarounds:
http://codeofrob.com/archive/2010/02/14/multi-tenancy-in-asp.net-mvc-controller-actions-part-i.aspx
This is a pretty good solution:
http://mvcex.codeplex.com/
Google for "mvc multitenancy" for other examples.
我在 Zack Owens 的博客中找到了另一个解决方案,可以找到 此处。感谢您的所有建议和想法!
I have found another solution to do this in the Blog of Zack Owens which can be found here. Thank you for all of your suggestions and ideas!