Swoop
Swoop

Reputation: 1423

How can you share a master page between 2 different projects/apps in ASP.NET MVC?

Is there a way to share a master page between different MVC projects/applications?

We have several different applications, and would like those apps to share a similar header and footer on the web pages.

What is the best approach to handle this situation with ASP.NET MVC?

Upvotes: 3

Views: 1656

Answers (3)

chris
chris

Reputation: 37450

Without some tricks, you can't do it. And as @MedicineMan mentions, the workarounds will depend somewhat on your source control system.

One way to deal with this is to add pre and/or post build steps to your project, which copy a version of the file into the other the projects. You'll need to include the master as a item in the project, and some version systems clients will want to include the copy of the file.

Upvotes: 1

Dustin Laine
Dustin Laine

Reputation: 38503

I do not believe you can share master pages, but I have done something like this with MVC.

I have a website project and and administrative project, both MVC 2 applications. I have a master page for both projects. I then create a "ResourceURL" app setting in the web.config. From there I prefix all "resource" assets with that config entry. Now I store all my web files like CSS, scripts, images, etc int he website project and reference them from both projects.

This also works nicely to allow for a CDN integration down the line.

Upvotes: 1

MedicineMan
MedicineMan

Reputation: 15314

To accomplish this, wouldn't you also need to share CSS, Images, and scripts? Are you sharing them between solutions or projects?

It sounds like to answer this, you would also need to answer the question: How can I share files between 2 different solutions / projects. I think that answer is somewhat dependent on what kind of revision control system you are using.

Upvotes: 0

Related Questions