Solved

ASP Include

Posted on 2011-09-13
13
245 Views
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:
http://server1.com/header.php
http://server1.com/footer.php

I need these files to be included into this file here below:
http://server2.com/main.asp

Is there a way to include files in ASP like we can in PHP (<? include("http://server1.com/header.php"); ?>) or should I use Java script?


Thank you in advance for all the help.
JC
0
Comment
Question by:jccyber
13 Comments
 
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
0
 

Author Comment

by:jccyber
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?
0
 
LVL 9

Expert Comment

by:dexterrajesh
ID: 36527715
hi,

you can try the iframe to page include... Its an old method but should work...
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
0
 
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.

http://p2p.wrox.com/classic-asp-databases/6546-include-php-inside-asp-file.html
0
 

Author Comment

by:jccyber
ID: 36528028
Will ASP do the same thing for all ssi files? If I use header.shtml instead will it process it
0
 

Author Comment

by:jccyber
ID: 36528034
Ahh I See point taken!!!
0
 
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.

Carrzkiss
0
 
LVL 83

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("http://server1.com/header.php"); ?>), the PHP will execute on that server and you will get the results, the HTML output from the PHP, not the code itself.
0
 

Author Comment

by:jccyber
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?
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36528211
0
 
LVL 9

Accepted Solution

by:
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.

<%=remoteinclude("http://server1.com/header.php","http://server1.com/")%>

<%=remoteinclude("http://server1.com/footer.php","http://server1.com/")%>

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
objXMLHTTP.Send
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
%>
<html>
<head>
<title>Remote Include</title>
</head>
<body>
First URL:<br>
<%=remoteinclude("http://php.net/manual/en/curl.examples.php","http://php.net/manual/en/")%>
Second URL:<br>
<%=remoteinclude("http://www.w3schools.com/php/","http://www.w3schools.com/php/")%>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:jccyber
ID: 36711795
Thank you Experts.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 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