What is the best way to share MasterPages across projects

前端 未结 7 1035
别那么骄傲
别那么骄傲 2020-12-09 09:10

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

相关标签:
7条回答
  • 2020-12-09 09:35

    From K. Scott Allen's ASP.Net Master Pages: Tips, Tricks, and Traps article, on "Sharing Master Pages":

    The first alternative is to copy shared master page files into a single location on an IIS web server. Each application can then create a virtual directory as a subdirectory and point the virtual directory to the real directory of master pages. The applications can then set the MasterPageFile property of a page to the name of the virtual directory, plus the name of the master page file. When we drop an updated master page file into the real directory, the new master page will appear in all the applications immediately.

    A second approach is to use a version control system to share a set of master page files across multiple projects. Most source control / version control systems support some level of “share” functionality, where a file or folder can appear in more than one project. When a developer checks in an updated master page file, the other projects will see the change immediately (although this behavior is generally configurable). In production and test, each application would need to be redeployed for the update master page to appear.

    Finally, the VirtualPathProvider in ASP.NET 2.0 can serve files that do not exist on the file system. With the VirtualPathProvider, a set of master pages could live in database tables that all applications use. For an excellent article on the VirutalPathProvider, see “Virtualizing Access to Content: Serving Your Web Site from a ZIP File”.

    0 讨论(0)
提交回复
热议问题