ASP Include

Posted on 2011-09-13
Last Modified: 2013-11-18
Hello Experts,

I am not savvy in ASP! however i found myself in this dilemma where I have to include 2 php files in an ASP file on a different server!!

Yes Ouch!

I have the 2 files:

I need these files to be included into this file here below:

Is there a way to include files in ASP like we can in PHP (<? include(""); ?>) or should I use Java script?

Thank you in advance for all the help.
Question by:jccyber
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36527703
I think we can not do that operation. Because both are different server side languages and both are using their own compiling and running method

Author Comment

ID: 36527710
Yes for sure! however the PHP files are already processed on server1 I am trying to pull the output in the ASP file is this possible?

Expert Comment

ID: 36527715

you can try the iframe to page include... Its an old method but should work...
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36527719
already processed on server1
did you mean you got the HTML output which is fixed ?

then you can copy and embed it in asp page
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36527744
when you use #include in ASP, what happens is the server takes all the code files and puts them together into one long script. This includes the originally requested ASP, and any include files. The important thing is that all those files are being processed by the ASP script engine. Any file you include will get processed by the script engine (regardless of the file extension). So it will process anything between <% and %> within that file as if it were in the original ASP file.

Point of this babble is that if you #included a PHP file, most likely you'll end up with PHP script bleeding onto your page because ASP will ignore the <?php ...?> tags.

Author Comment

ID: 36528028
Will ASP do the same thing for all ssi files? If I use header.shtml instead will it process it
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails


Author Comment

ID: 36528034
Ahh I See point taken!!!
LVL 30

Expert Comment

by:Wayne Barron
ID: 36528127
Convert your php scripts over to asp classic.
If you can show what the code is, we can try to assist in the conversion process.

LVL 82

Expert Comment

by:Dave Baldwin
ID: 36528134
You can Not include PHP Code from another server, you can Only do that with a local file.  If you use a URL to 'include' a PHP page like (<? include(""); ?>), the PHP will execute on that server and you will get the results, the HTML output from the PHP, not the code itself.

Author Comment

ID: 36528196
I just need the output not the code. I am simply trying to include a file from an offsite server in an asp file.

If there is a way to include an offsite file .html, .txt into an .asp file?
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36528211

Accepted Solution

djpazza earned 500 total points
ID: 36528265
Yes you can, you need to read the remote webpage from the other two domains into a string and then display it back on your main.asp page using MSXML2.ServerXMLHTTP.

Put the attached asp function at the top of your main.asp page and then where you need the header and footer jthen ust call the function and pass two variables to it, full url and base url.



Attached code is a full demo of getting two different php pages onto a single asp page.
function remoteinclude(remoteurl,remoteroot)

Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "GET", remoteurl, False
strPageText = objXMLHTTP.responseText
Set objXMLHTTP = Nothing

' In case assets do not contain full URL set base page

strpage = replace(strPageText,"</HEAD>","<BASE HREF=""" & remoteroot & """></HEAD>")
strpage = replace(strPageText,"</head>","<BASE HREF=""" & remoteroot & """></head>")
' Output the results
response.Write strpage
end function
<title>Remote Include</title>
First URL:<br>
Second URL:<br>

Open in new window


Author Closing Comment

ID: 36711795
Thank you Experts.

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Form submit issue 11 54
XML Parsing Classic ASP 5 42
Select distinct 25 60
Import csv files to MS SQL 5 60
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now