views:

149

answers:

2

One of the projects I was in charge of as a JSP/Struts developer at my last employer was a themes tag library (present on every WebSphere server as a shared library) that let any Java web dev in the company pull in any of the standard themes like intranet, public, etc. with minimal effort. The themes included header, footer, navigation, and links to css & javascript, etc. They could even customize things a bit when we gave them the option, like choosing a selected tab.

This setup was ideal because we could make centralized change to any standard UI elements and they were automatically pulled in by all sites using themes without any effort by the site developer.

With the new job I started in December, I've switched to using ASP.NET. I'd like to propose something similar in spirit to the themes app here, since we're running a bunch of different sites that should have a unified look and feel.

What's the best way to accomplish this? I'd rather not have to recompile anything to update the theme to make this work.

Edit:

Although I was hoping for a better answer, the .NET gods apparently don't approve of what I was trying to accomplish. Here are the three options that were found:

  1. Compile a Master Page into a DLL and put it into the GAC: This works in simple cases, but as a hack it's too brittle. I couldn't get it to work correctly with our site.

  2. Create a virtual directory to the Master Page in each web app: This actually does work, although it doesn't make for a very comfortable development environment. However, one of the things we are trying to move away from is having to create virtual directories inside each web application. No dice.

  3. Create a bunch of custom controls, compile them into a DLL, and put it into the GAC: This is the answer I selected. It's the least centralized option and requires more work for the developer of each site, but it seems to be the only Microsoft-blessed way.

In conclusion, I'm pretty frustrated with .NET over this. In the grand scheme of things Master pages are just code, and I don't see any reason why they couldn't be easily centralized for use in multiple web applications. This seems to be a major loss compared to JSP/Java.

A: 

You can put some UI into the form of custom controls or server controls (if not in MVC) and then place them in the GAC thereby distributing them. All references to the controls in that assembly will be pulled from the latest version in the gac. You can also do things via the Machine.config which is controlled at the server level rather than the app level.

Andrew Siemer
A: 

I am not sure if this is the best approach, but I have always used ASP.NET Master Pages to create a consistent look and feel.

You could share the Master Pages across the different sites, and put enough Content Placeholders to allow for sufficient changes within each specific site.

You can read more about Master Pages here: http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

And information on sharing Master Pages between web applications here: http://msdn.microsoft.com/en-us/library/aa992039(VS.80).aspx

Matt