Solved

IIS ASP: How to display another web page within an .asp page

Posted on 2007-11-16
18
891 Views
Last Modified: 2010-04-21
I have a URL (on the same site, with several GET parameters), that needs to be displayed in the middle of another page.

in PHP i would do it with readfile or require
<?php readfile("http://xxx.com/list.pl"); ?>

i know very little about IIS and ASP, so exact syntax would be helpful.

many thanks
0
Comment
Question by:willsherwood
  • 7
  • 6
  • 2
  • +1
18 Comments
 
LVL 15

Assisted Solution

by:spprivate
spprivate earned 100 total points
ID: 20300739
can u be more specific please.Normally to show two webpages in a single page we use frames.
Is that what you are looking for
0
 

Author Comment

by:willsherwood
ID: 20301010
sorry i want to use an include or require type of feature, not frames.
the example i have works fine in PHP on Apache using readfile(... URL )

0
 
LVL 15

Assisted Solution

by:spprivate
spprivate earned 100 total points
ID: 20301080
Normally I use
<!-- #include file="../../menu.asp" -->

to include a page in another asp.
This should work
0
 

Author Comment

by:willsherwood
ID: 20301159
the above appears to be a filesystem path.
is there a way to include an http protocol URL?
0
 
LVL 20

Assisted Solution

by:jitganguly
jitganguly earned 50 total points
ID: 20301261
How do I read the contents of a remote web page?    
You can include static txt and HTML files from remote servers by using a component (such as AspHTTP (http://www.serverobjects.com/products.htm), ASPTear (http://www.alphasierrapapa.com/ComponentCenter/AspTear/), or VB's built in InetCtrls) to parse the remote URL's content.
 
You can also try this method out, it uses the MSXML objects which are installed with Windows 2000 (or you can download them here (http://download.microsoft.com/download/xml/Install/3.0/WIN98Me/EN-US/msxml3.exe) for other operating systems):
 
<%
    url = "http://www.espn.com/"
    set xmlhttp = server.CreateObject("Microsoft.XMLHTTP")
    xmlhttp.open "GET", url, false
    xmlhttp.send ""
    Response.write xmlhttp.responseText
%>

use fso to write to a file, you need to set proper permissions on the server to create and write to a file (give the IUSR_webservername write permissions in the directory targetted)

<%

' create the fso object

set fso = Server.Createobject("Scripting.FileSystemObject")

path = "c:\temp\test.txt"

strDate = Replace(Date(), "/", "")

strDir = "c:\inetpub\wwwroot\articles\" & strDate

strNewFileName = Hour(Now) & "_" & Minute(Now) & "_" & second(Now) & ".html"



' open the old file

set file = fso.opentextfile(path, 1)  <-- For reading

strText = file.readall

set file = nothing



' check for and/or create folder

if not fso.folderexists(Server.MapPath(strDir)) then

     set f = fso.CreateFolder(Server.MapPath(strDir))

else

     set f = fso.GetFolder(Server.MapPath(strDir))

end if



' create and write new file

set file = fso.Createtextfile(f.path & "\" & strNewFileName)

file.write(strText)

set f = nothing

file.close

set file = nothing



' delete the old file

fso.DeleteFile(path & "\" & rst("FileName") & i)



' clean up

set fso = nothing

%>

also check these links for more:
http://www.4guysfromrolla.com/webtech/090599-1.shtml
http://www.15seconds.com/Issue/000816.htm
http://msdn.microsoft.com/library/devprods/vs6/vbasic/vbenlr98/vaobjfilesystemobject.htm
0
 
LVL 10

Expert Comment

by:effx
ID: 20303893
Try (may work):

<script type="text/javascript" language="javascript">
function ajaxFunction(pagetoget, element_name){
//By EFFXDesign.com
var xmlHttp;
      try{xmlHttp=new XMLHttpRequest();}    // Firefox, Opera 8.0+, Safari
      catch (e){    // Internet Explorer
            try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
            catch (e){
                  try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
                  catch (e){
                        alert("Your browser does not support AJAX!");
                        return false;
                  }
            }
      }
    xmlHttp.onreadystatechange=function(){
            if(xmlHttp.readyState==4){
                  document.getElementById(element_name).innerHTML=xmlHttp.responseText;
            }
      }
    xmlHttp.open("GET",pagetoget,false);
    xmlHttp.send(null);
}
</script>
<div id="op">Loading Page....</div>

<script type="text/javascript" language="javascript">
ajaxFunction('http://www.yahoo.com/', 'op');
</script>
0
 
LVL 10

Expert Comment

by:effx
ID: 20303906
<%
domain = "http://www.effxdesign.com/"
path_to_files = ""
page_to_get = domain & path_to_files
browser_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"' 'setting browser type
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
      objHttp.open "POST", page_to_get, false
      objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
      objHttp.setRequestHeader "USERAGENT", browser_agent
      objHttp.setRequestHeader "RETURNTRANSFER", 1
      objHttp.setRequestHeader "SSL_VERIFYPEER", false
      objHttp.setRequestHeader "SSL_VERIFYHOST", 0
      objHttp.Send str
      page_result = objHttp.responseText
set objHttp = Nothing
page_result = replace(page_result, "=""/", "=""" & domain & "")
Response.Write(page_result)
%>
0
 
LVL 10

Expert Comment

by:effx
ID: 20303911
the reason i split the domain and the path is so that wil can re write the paths on the page loaded from the other site.

the Replace statement actually replaces all the:

/

with

http://www.effxdesign.com/

this gives the correct output display.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:willsherwood
ID: 20313116
it worked fine.
we're very happy
thanks
0
 

Author Comment

by:willsherwood
ID: 20313203
i spoke too soon.
the effx script displas successfullyy the results of the root URL without applying the GET parameters.

the actual statement below is:

<%domain = "http://xxx.edu/axs/ax-admin.pl?maximum=&format=Sort+All+by+Time&s11=CHECKED&MakeGraphs=View+in+Graphical+Format&start_date=&end_date=&Filter="

what are we doing wrong to have it ignore the GET parameters

thanks for your continued patience

0
 
LVL 10

Expert Comment

by:effx
ID: 20313815
Did you use the ASP or the Javascript ?
0
 
LVL 10

Accepted Solution

by:
effx earned 350 total points
ID: 20313829
:-)
<%

domain = "http://xxx.edu/"

path_to_files = "axs/ax-admin.pl?maximum=&format=Sort+All+by+Time&s11=CHECKED&MakeGraphs=View+in+Graphical+Format&start_date=&end_date=&Filter="

%>

Open in new window

0
 

Author Comment

by:willsherwood
ID: 20315160
EXCELLENT!  
0
 
LVL 10

Expert Comment

by:effx
ID: 20322814
So I wrote the coed and got no points ?
0
 
LVL 10

Expert Comment

by:effx
ID: 20322830
This sort of thing makes me think what a waste of time experts exchange is.
0
 

Author Closing Comment

by:willsherwood
ID: 31409624
this (new) scoring was my original intent, not sure what went wrong?
i was very pleased, and sorry for the mishap, certainly no hidden agenda or ill-intent!   you guys are great.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

Here are the symptoms: You start receiving calls from users that one of your legacy web apps isn't coming up, so you log into your IIS 5 server to check it out.  When you pull up the services, you notice that the WWW Publishing service isn't runn…
Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

21 Experts available now in Live!

Get 1:1 Help Now