Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2004, 08:58 PM
Authorized User
 
Join Date: Apr 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get source code

Hi there! Does anyone know how I can retrieve the source code of a given URL in ASP?

I tried using Internet Transfer Control but I found out that Visual Basic must be installed in the server first before it can work. Are there other ways on how I can retrieve the source code without the need to install other components?

Thanks
 
Old September 27th, 2004, 09:29 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

You can not retrieve the source code of ASP or PHP, I believe this goes for all server side web scription languages.(unless directory browsing is turned on, this is an IIS setting that makes all your code avaible to EVERYONE)

BTW: This is a good thing. Server side scripters get paid much more than clint side guys, this is one of the main reasons why.

You say:
;;;retrieve the source code of a given URL in ASP?

You can retireve the URL using server variables. If this is what you are after here is a script that shows you all available server variables.

(the one you are after is request.servervariables("PATH") for thr URL)

------------------cut n paste code--------------------
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" width="750">
<tr>
<td valign="top" align="left" width="150"><b>Variable Name</b></td>
<td valign="top" align="left" width="600"><b>Value</b></td>
</tr>
<%
for each name in request.servervariables
%>
<tr>
<td valign="top" align="left" width="150">

<%= name %></td>
<td valign="top" align="left" width="600">
<%= request.servervariables(name) %></td>
</tr>

<%
Next
%>
</table>
</div>
------------------------finish----------------------


Wind is your friend
Matt
 
Old September 27th, 2004, 11:48 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Do you want to retrieve the HTML that a given ASP page generates ? If yes, you can use XMLHTTP object. This will be normally available in windows 2000 and above by default. If it is not available, you can MSXML library (available free of cost at microsoft site) on the server.

Here is a sample code to use with XMLHTTP object.

on error resume next
dim str_html
dim obj_source_page
Set obj_source_page = Server.CreateObject("Msxml2.SERVERXMLHTTP")
obj_source_page.Open "GET", "http://www.yoursite.com", False
obj_source_page.Send
If Err.Number <> 0 Then
    Response.Write("Your web site does not appear to be up right now. Please try again later.")
    Err.Clear
Else
    str_html = obj_source_page.ResponseText
End If

After running this script, str_html contains the html generated by the default page of www.yoursite.com

Hope this helps

Madhu
 
Old September 28th, 2004, 02:46 AM
Authorized User
 
Join Date: Apr 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! I tried using XMLHttp and it works. However, I tried running the code in other pcs but in some, it won't work. I can't remember if I've installed the MSXML library in my pc that's why it's working here..but will you know if XMLHTTP can already be found in Windows2000 or do I have to install the MSXML library?
 
Old September 28th, 2004, 06:19 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I am not sure about this. My previous win 2k installation was running this component without any problem. When I re-installed it recently, this component stopped working. I had to run the MSXML library after downloading from MS.

I don't know which installation option is installing this component. May be somebody else can help us.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Code nappydyno234 Java Basics 6 March 25th, 2007 06:49 AM
source code in C# rajum BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 December 26th, 2006 09:06 AM
where is the source code allenjiang Wrox Book Feedback 2 November 1st, 2006 01:32 AM
Source code amit_Kinariwala All Other Wrox Books 2 February 17th, 2004 12:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.