MVC项目架构,支持模块 [英] MVC project architecture supporting modules
问题描述
我需要我的MVC 3.0项目支持的模块。通过模块我的意思是有独立的库,其中包括模型视图和controlers。这样做的原因是为具有可以由多个应用程序使用的应用程序的可重复使用的部件。
I need my MVC 3.0 project to support modules. By module I mean having separate library which includes models views and controlers. The reason for this is to have reusable parts of application which can be used by multiple applications.
对我最好的就是让这些模块作为一个MVC应用 - 有ReSharper的,MVC Visual Studio的插件工作。我的意思是智能感知,导航CONTROLER,查看和创建CONTROLER屏幕等。如果我inlcude一般类libraty这些类,功能也没有了。
The best for me would be to have those modules as an mvc applications - to have resharper, mvc visual studio addons working. I mean intellisense, controler navigation, view and controler creation screens etc. If I inlcude those classes in general class libraty, the functionality is gone.
设置应用程序中使用我的控制器从模块应用程序相当简单。
setting the application to use my controllers from "module" application is fairly simple.
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
, new[] { "ModuleApplication1.Controllers" }
);
问题是,视图,控制器试图加载不在当前应用程序present,但它在我的模块的应用程序。更糟糕的是 - 观点没有编制,也没有嵌入在DLL中的。我不惯于复制它们。我preFER从DLL加载它们。如果这是可能的。
the problem is that the view, the controller is trying to load is not present in current application, but it's in my "module" application. Even worse - the views are not compiled nor embedded in the dll at all. I don't wont to copy them. I prefer to load them from the dll. If it's possible.
我承认,我是新来的MVC。
I admit, I'm new to MVC.
我缺少的东西吗?有没有解决这个?是我的做法完全错误的?
Am I missing something? Is there any solution to this? Is my approach totally wrong?
推荐答案
您可以使用 MvcContrib 便携式领域,他们正是为此而设计的方案。
You can use MvcContrib Portable Areas, they're designed exactly for this scenario.
这篇关于MVC项目架构,支持模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!