#include virtual
am 24.01.2008 14:20:04 von 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
Re: #include virtual
am 24.01.2008 17:22:32 von 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.
--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
"milop" wrote in message
news:u5W$ovoXIHA.3688@TK2MSFTNGP04.phx.gbl...
> 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
>
Re: #include virtual
am 24.01.2008 18:41:46 von 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
"Mark Fitzpatrick" wrote in message
news:99DEA9DF-11ED-4272-9487-CCD4586CFD1B@microsoft.com...
> 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.
>
>
> --
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - Expression
>
>
> "milop" wrote in message
> news:u5W$ovoXIHA.3688@TK2MSFTNGP04.phx.gbl...
>> 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
>>
>