faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

25 of 39 people (64%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How can I include an ASP page in another ASP page?

Apr 23rd, 2005 04:15
Keyar Srinivasan, Mike Hall, unknown unknown,


You can use server-side includes to pull the contents of one file into 
another. Here's an example using two files:
  Filename: hello.inc
  ........................................
    Hello World!
  ........................................
  Filename: sample.asp
  ........................................
    <html>
    <head></head>
    <body>
    <!-- #include file="hello.inc" -->
    </body>
  ........................................
The result is the same as if you had one file like this:
  ........................................
    <html>
    <head></head>
    <body>
    Hello World.
    </body>
  ........................................
You can use HTML and/or ASP code in the included file and it is 
processed just as it would be if it were actually coded in the 
including 
file. By convention, included files are usually given a .inc extention 
but you can use .html or .asp as well.
The #include directive allows the file to be specified using relative 
path references on the file parameter:
  <!-- #include file="xyz/abc.inc" -->
  <!-- #include file="../abc.inc" -->
  <!-- #include file="../xyz/abc.inc" -->
To include files located in a virtual server directory, use the virtual 
parameter:
  <!-- #include virtual="/iissamples/issamples/adovbs.inc" -->
One note, by default most IIS web servers only allow #include to be 
used 
in .asp files. Unless your host has been configured differently, 
#include will not work when used in .html or other files.
--------------------------------------------------------
Have anybody Tried this, as For example You are having an asp 
file "index.asp" in http://www.yourwebsite.com/ which have the inc 
file included as "xyz/abc.inc", Now if u try 
http://www.yourwebsite.com/xyz/abc.inc , If the inc is non executable 
file, it will display the Full code. So if u have used any Connections 
in this, this will be a non secure page. Some times this will be 
indexed too [in few occassions]. 
We can include an asp file into another asp file, Mostly that is Secure
  <!-- #include file="../xyz/abc.inc.asp" -->
Otherwise, we need to set off Read permission for .inc files, which 
will be more headache.
Good Luck....



© 1999-2004 Synop Pty Ltd