...

View Full Version : ASP Equivalent of file_get_contents?



Pennimus
10-10-2007, 03: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:



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

Daemonspyre
10-10-2007, 04: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...

Sorry...

Spudhead
10-10-2007, 05: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

Pennimus
10-10-2007, 05: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")
response.write(page)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum