开发者

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 di开发者_如何学Gofferent 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?


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜