MVC project architecture supporting modules

2019-06-24 08:08发布

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.

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

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.

I admit, I'm new to MVC.

Am I missing something? Is there any solution to this? Is my approach totally wrong?

1条回答
虎瘦雄心在
2楼-- · 2019-06-24 08:43

You can use MvcContrib Portable Areas, they're designed exactly for this scenario.

查看更多
登录 后发表回答