views:

542

answers:

3

I have some ASP.NET Master pages located in one assembly. I need to use these masterpages for my webform pages located in other asseblies that have a reference to the first assembly. I cannot seem to figure out a way to do this.

Is there a nice way that I can do this?

If you do not have a pretty solution I would also like to hear about possible hacks?

Thanks

+5  A: 

Master Pages are based upon Usercontrols, therefore they cannot be shared across applications.

That said, Dan Wahlin has a way around that particular limitation listed on his blog.

Stephen Wrighton
+2  A: 

Sharing Master Pages Across IIS Applications by Dan Wahlin will give you some ideas..

Also, check this excellent article by Scott Allen. You can check the last section at the end on sharing master pages.

Gulzar
A: 

There are no pretty solutions to this problem.

What you can do is put it into a separate web application project and pre-compile it. Then take the precompiled dlls and ILMerge them into a single dll that you can reference in your app.

The actual master page that you reference will have a class name like this: MyMasterPage_aweknk so look it up in reflector. The class that looks like "MyMasterPage" is really just the code-behind.

It's really disgusting, but it's what we've done to reuse user controls in multiple applications.

Ben Scheirman