ASP VIRTUAL keyword not working in ASP.NET anymore :S

  • Thread starter Dhruba Bandopadhyay
  • Start date
D

Dhruba Bandopadhyay

In classic ASP I could write:

<!-- #INCLUDE VIRTUAL="Kevin\General\ServiceClass.asp" -->

and it would "include" that ASP file into the current ASP file. My web
application folder was not stored in C:\Inetpub\wwwroot\ but somewhere else.
But the VIRTUAL command let IIS locate files by the IIS virtual folder.

Now in ASP.NET this does not work. It complains saying:

Could not find a part of the path
'c:\inetpub\wwwroot\Kevin\General\ServiceClass.aspx'



Is it possible creating a link/shortcut folder in \wwwroot\ ? Or how can I
get around this the easy way? I don't want to rename all VIRTUAL into FILE
and giving absolute paths.
 
G

Guest

ASP.net is a totally different thing to classic ASP, almost nothing works in
the same way and it is not really backwards compatable at all. The
functionality you want to acheive works in a totally different way. I sugest
you forget about everything you learned in ASP and aproach ASP.net as if you
were learning a new language from scratch.
 
G

Guest

In classic ASP I could write:

<!-- #INCLUDE VIRTUAL="Kevin\General\ServiceClass.asp" -->

and it would "include" that ASP file into the current ASP file. My web
application folder was not stored in C:\Inetpub\wwwroot\ but somewhere
else. But the VIRTUAL command let IIS locate files by the IIS virtual
folder.


You should be using usercontrols rather than includes. Does that solve your
problem?
 
J

Juan T. Llibre

re:
<!-- #INCLUDE VIRTUAL="Kevin\General\ServiceClass.asp" -->

Shouldn't that be :
<!-- #INCLUDE VIRTUAL="/Kevin/General/ServiceClass.asp" -->

?

VIRTUAL means, "virtual", clearly, and does not include physical paths.

re:
Could not find a part of the path 'c:\inetpub\wwwroot\Kevin\General\ServiceClass.aspx'

That makes sense.

IIS adds c:\inetpub\wwwroot because it knows that it's the root application,
and tries to locate the virtual path you specified.

The general way of including files based on physical paths is "include file" :

<!--#include file="ServiceClass.asp"-->

In general, though, in ASP.NET you shouldn't be using #INCLUDE to use code in other pages.
You should use user controls ( ascx ) or class files ( *.vb or *.cs ), or assemblies.
 
D

Dhruba Bandopadhyay

Yep you are right!

It was meant to be VIRTUAL="/Kevin/.....

Somehow in ASP it probably did a fail-safe when it saw VIRTUAL="Kevin/...
and tries http://localhost/Kevin.... address. But in ASP.NET is more
stricter and requires the VIRTUAL="/Kevin/.... where the first forward slash
/ signifies the root of the website space in http://localhost/

I just need to do a massive search & replace in my old ASP app and hope that
still works there too!
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top