Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts

    ASP Equivalent of file_get_contents?

    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 Code:
    <?php
        $ob 
    file_get_contents('http://www.domain.com/page.html');
        echo 
    $ob;
    ?>

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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...
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • Users who have thanked Daemonspyre for this post:

    Pennimus (10-10-2007)

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    I might be wrong, but wouldn't this do it:

    Code:
    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

  • Users who have thanked Spudhead for this post:

    Pennimus (10-10-2007)

  • #4
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    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...

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •