Suppose you have two seperate ASP.NET Web Application projects that both need to use a common MasterPage.
What\'s the best way to share the MasterPage across project
I cant see why you would want to have the same markup accross different projects, if you do, I dont know an easy way.
However with code, obviously you can write a code file which inherits from
System.Web.UI.MasterPage
Put in whatever logic you want in all your master pages in there. Build it as your awesome dll then just include that in your projects.
Keep a primary copy in source control, and let your source control system worry about it.
Supposing you can create a common repository for all your projects (a common folder in your source control tree, for example), you could add the master pages as links by using relative paths.
However, IIRC, Visual Studio makes local copies of files added from external paths. You might have to text-edit the solution/project file to add the linked files.
This, of course, is assuming you use "Web Application" format. Older VS "Web Sites" do not have project files and rely on having all files within the site folder.
Use a symbolic link:
A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.
AFAIK there is no elegant way to do what you are looking to.. VS will always end up copying it.
I think to be honest it may not be a great idea.. Obviously you want to share the lowest common code, but a whole MasterPage?.. Sounds like you could be asking for trouble since one minor change could have such an impact on one or more applications..
I would suggest instead seperating out the good bits of functionality into components/controls and deploying them.
I have trying to accomplish the same thing. I look into a couple of solutions but I think using a virtual directory is probably the best way to share master pages.
Here are a couple sources that you can look at.
The third bullets near the end the article tells you of possible ways you can share Masterpages also.