Solved

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

Posted on 2007-11-16
18
908 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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
 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is there any way to limit concurrent connection in IIS7? 6 49
ASP exit 10 26
ASP and Extracting XML 7 24
Record locking on classic ASP 3 35
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

680 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