I have an assembly that is the core of a framework for a group of applications. The framework includes some shared base classes, some common pages, some master pages, and some controls. I am building the assembly into a single dll using a Web Deployment
Project.
I have indicated in the Web Deployment Project that all code should be built into a single assembly. That is working correctly. I have also indicated in IIS that the server should not check for the physical existence of .aspx, .ascx, and .master files.
In the code of a particular page on my site (outside of the framework project), I am setting the MasterPageFile to one of the master pages in the framework assembly. When I load the page in the browser, I get an error indicating that the master page doesn't
exist.
I would greatly appreciate any pointers on referencing a master page built into an assembly from a page in another project.
My suggestion would be to look at using a VirtualPathProvider. Unlike UserControls, which we can load by Type or from a physical .ascx file, I think the runtime is always going to look for a .master file on disk. With the VirtualPathProvider you can make
the .master file appear as if it is on disk. Good article on the topic here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/vpp_vga.asp.
This seems like an interesting project. I'd like to try it sometime. Let me know if you can make some progress.
Scott
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
I know it's been a while since the last post on this topic, but were you able to get this working using the virtual path suggestion? I'm trying to do something very similar. Thanks
Yes. The virutal path provider suggestion worked well. We were able to embed all of the shared resources (Master page files, etc) into the our framework assemblies and reference it at runtime from other assemblies.
That's good news. I've been trying to solve this problem using a different approach....building an instance of the master page and disregarding the master page file. I'm close but having problems with master pages that extend other master pages. Using a virtual
path provider sounds like a more elegant/appropriate solution. I guess the first step is to get the master page files in the assembly...which I haven't successfully done yet. I'm using the Web Deployment Project to build my assembly. Were you able to do that
using WDP? I couldn't get any of my static files (stylesheets, etc.) into the assembly using WDP. Also, I'm not familiar with the virtual path provider (yet). Any words of advice or code samples on either of those fronts you might be willing to share? Thanks
for the reply either way...it's good to hear it's possible. I'm very new to .NET...I know what I want to do, just now how to do it yet. Thanks again
caldwell_jas...
Member
20 Points
5 Posts
Referencing a master file built into an assembly.
Apr 11, 2006 06:04 PM|LINK
I have an assembly that is the core of a framework for a group of applications. The framework includes some shared base classes, some common pages, some master pages, and some controls. I am building the assembly into a single dll using a Web Deployment Project.
I have indicated in the Web Deployment Project that all code should be built into a single assembly. That is working correctly. I have also indicated in IIS that the server should not check for the physical existence of .aspx, .ascx, and .master files.
In the code of a particular page on my site (outside of the framework project), I am setting the MasterPageFile to one of the master pages in the framework assembly. When I load the page in the browser, I get an error indicating that the master page doesn't exist.
I would greatly appreciate any pointers on referencing a master page built into an assembly from a page in another project.
bitmask
Contributor
6739 Points
1245 Posts
MVP
Re: Referencing a master file built into an assembly.
Apr 12, 2006 03:43 AM|LINK
My suggestion would be to look at using a VirtualPathProvider. Unlike UserControls, which we can load by Type or from a physical .ascx file, I think the runtime is always going to look for a .master file on disk. With the VirtualPathProvider you can make the .master file appear as if it is on disk. Good article on the topic here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/vpp_vga.asp.
This seems like an interesting project. I'd like to try it sometime. Let me know if you can make some progress.
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
fritz
Member
29 Points
9 Posts
Re: Referencing a master file built into an assembly.
Oct 27, 2006 06:15 PM|LINK
caldwell_jas...
Member
20 Points
5 Posts
Re: Referencing a master file built into an assembly.
Oct 27, 2006 07:41 PM|LINK
fritz
Member
29 Points
9 Posts
Re: Referencing a master file built into an assembly.
Oct 28, 2006 06:03 AM|LINK