views:

1052

answers:

5

We would like to have several internal web applications which use the same master page. Is there a way to store a master page in a common library referenced by all projects?

A: 

I've heard this works, I haven't tested it.

Create a separate project to house your master pages, since all master pages are like user controls and built into their own separate assembly. Run the build and try referencing the assembly of the master page.

Again, not tested, just something I've read before.

G'luck with it!

thismat
+1  A: 

You can do this, but it is difficult and has quite a few drawbacks.

This process is similar to packaging up user controls as well. Basically you have a web application project that contains your master page. You can precompile this into a set of dlls using aspnet_compiler.

then you can use ilmerge.exe to put them all into a single dll that you then reference from your other projects.

You still need to have the markup in order for your pages to render properly in the designer, so you'll probably have to investigate VirtualPathProviders as well.

It's a kludgy solution and it has many drawbacks.

Ben Scheirman
A: 

Maybe this excellent tutorial on www.asp.net could be helpful to find a solution.

Look for the section "Creating a Custom Base Master Page Class."

splattne
A: 

Given that these modules are part of the same web application, you should look at this approach:

Basically, you have one root web, which is set up as the(only) IIS web application. You may plug in new web modules by creating ASP.NET Web Application projects and place under the root web, physically. Set the build directory to root web's bin, eg. "..\bin". Don't create a IIS application/virtual directory.

Thereby, each web module compiles into its own DLL, which is itself a good thing. When compiling, it is "merged" with the root web.

It is a great way for sharing master pages and user controls, and have different parts of the web site in different projects/assemblies. Master pages and user controls will even work in design mode.

baretta
A: 

Hope this helps Sharing master page across the application

Enjoy.. :)