View Full Version : ASP Equivalent of file_get_contents?

10-10-2007, 02:46 PM
I'm having no luck finding this, everything I see seems far too complex for this simple operation. Can some bright spark point me in the right direction?

Here's the PHP:

$ob = file_get_contents('http://www.domain.com/page.html');
echo $ob;

10-10-2007, 03:04 PM
Unfortunately, there isn't a truly easy way to do this in ASP. At least not that I know of.

You could use AJAX to pull the file over to the server, then use the Scripting.FileSystemObject to write the page to a string.

Complicated it is, as M$ never thought that anyone would ever want to use this feature...


10-10-2007, 04:21 PM
I might be wrong, but wouldn't this do it:

function file_get_contents(sURL)
dim xmlhttp, sResult
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET",sURL, false
xmlhttp.send sURL
sResult = xmlhttp.ResponseText
set xmlhttp = nothing
file_get_contents = sResult
end function

10-10-2007, 04:59 PM
Okay, thanks. And does this look right for actually using said function, as currently this just causes a redirect to the root of the domain that I put this script on...

dim page
page = file_get_contents("http://www.domain.com/page.html")

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum