#include virtual

M

milop

Hello.

Using VS2005, I have a solution with two web application projects.

The web server for each project is IIS. I've created two virtual
directories, project1 and project2, under the same web site.

A page in project 2 (index.aspx) references images and the like in project 1
by using #include virtual="/project1/images/logo.gif". This works fine. It
also includes a reference to an .aspx page (header.aspx). The include looks
like this: : #include virtual="/project1/header.aspx".

I've run into a problem when referencing the .aspx page. The error is:
Parser Error: Could not load type "project1.header". The page directive in
project2's page looks like this: <%@ Page Language="vb"
AutoEventWireup="false" CodeBehind="header.aspx.vb"
Inherits="project1.header" %>

If I reference header.aspx directly (http://localhost/project1/header.aspx)
everything is fine.

So, I'm wondering why #include is not working. It seems as though the
ASP.Net runtime is not compiling project1.

Does anyone have any thoughts?

Thanks in advance,

Mike
 
M

Mark Fitzpatrick

The pages in project1 are compiled, but they are not compiled in project2.
If you reference it directly it's working because it's a completely seperate
application space, and the dlls are compiled there. Project2 can't reference
the header from project1. What you're doing is actually not a good
architecture principal. You don't want to step over application boundaries
like this, that's why you haev things like virtual directories.

What you could try doing is to put the files that you need shared into a
virtual directory. These files cannot have code-behind, unless you compile
them seperately and put the dll into the bin directory of each application
that will use them. You could put the code within the page itself and that
will be easier. So, instead of having the header as an ASP.Net page, make it
an ASP.Net user control. That is exactly what they were designed for. Then
you can insert the control from the virtual directory into your page without
using server side includes, use the standard ASP.Net reference mechanism.
 
M

milop

Hi, Mark. Thanks for responding.

Yeah, the cause of the problem that you described is pretty much what I
figured, thanks for verifying it.

I thought about using controls. The problem is that we need to be able to
deploy project1 and project2 independently. So having references is not
possible, and thus using User Controls is not possible because, as you
probably know, they cannot be shared amongst applications.

But, Custom Controls can be shared. Maybe that's the way to go.

What do you think?

Thanks again,

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top