Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an ASP.net MVC project as a "base" project for other MVC projects

I’m currently working on “suite” of internal intranet applications

They are all asp.net MVC apps, which will be (for various reasons) deployed as separate apps

I’m currently facing massive amounts of duplication -

Each app has essentially the same “outer” shell This outer shell isn’t just about views, it encompasses authentication logic etc…

The “inner” view is the actual app.

So, in an ideal world, I’d have something like:

MyCompany.Web
Holds the _Layout, base controllers, auth etc…

Then, other mvc projects in my solution such as:

  • MyCompany.Web.App1
    inherits MyCompany.Web

  • MyCompany.Web.App2
    inherits MyCompany.Web

etc…

Is there anything I could sensibly do to facilitate this?

Everything I’ve tried so far involves xcopying views etc.. into sub projects on builds, and feels very fragile.

like image 288
Alex Avatar asked Oct 02 '14 17:10

Alex


1 Answers

Create nuget packages for all assembly based code to be shared.

Consider whether nuget packages make sense for any view or layout file sharing.

Consider making a project template that includes usages of the relevant nuget packages. This will allow you to follow the same pattern MVC itself is taking that you can create a new project and update nuget packages as necessary. This eliminates the need for frequent changes to the template itself, except where changes aren't readily shared by nuget.

like image 87
Chris Marisic Avatar answered Sep 28 '22 10:09

Chris Marisic