简体   繁体   English

MVC项目架构支持模块

[英]MVC project architecture supporting modules

I need my MVC 3.0 project to support modules. 我需要我的MVC 3.0项目来支持模块。 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. 这样做的原因是拥有可重复使用的应用程序部分,这些部分可以被多个应用程序使用。

The best for me would be to have those modules as an mvc applications - to have resharper, mvc visual studio addons working. 对我来说,最好的办法是将那些模块作为MVC应用程序-使Resharper,MVC Visual Studio插件正常工作。 I mean intellisense, controler navigation, view and controler creation screens etc. If I inlcude those classes in general class libraty, the functionality is gone. 我的意思是智能感知,控制器导航,视图和控制器创建屏幕等。如果我将这些类包括在通用类libraty中,则功能将消失。

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" }
        );

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. 更糟糕的是,这些视图根本没有被编译或嵌入到dll中。 I don't wont to copy them. 我不会复制它们。 I prefer to load them from the dll. 我更喜欢从dll加载它们。 If it's possible. 如果它是可能的。

I admit, I'm new to MVC. 我承认,我是MVC的新手。

Am I missing something? 我想念什么吗? Is there any solution to this? 有什么解决办法吗? Is my approach totally wrong? 我的方法完全错误吗?

您可以使用MvcContrib便携式区域,它们是专门为这种情况而设计的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM