• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

ASP .NET equivalent of PHP's cURL

Question

whitebread    54

I am writing an ASP .NET website in VB .NET, and need to make a call to an external website (like cURL in PHP). My host is GoDaddy. I found this article on using cURL with GoDaddy which says GoDaddy uses a proxy server. Here is an example of PHP code making use of the GoDaddy proxy:

<?php

$url = "http://www.google.com/";

$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);

curl_setopt ($ch, CURLOPT_PROXY,"http://64.202.165.130:3128");

curl_setopt ($ch, CURLOPT_TIMEOUT, 120);

$response = curl_exec ($ch);

if(is_int($response)) {

die("Errors: " . curl_errno($ch) . " : " . curl_error($ch));

}

curl_close ($ch);

print "Remote Site : $url<br /><hr />$response";

?>

Can someone tell me how I would develop an equivalent function in ASP .NET (using the proxy)?

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
ZakO    554

Use the WebRequest and WebProxy classes, e.g:

WebRequest request = WebRequest.Create(url);
request.Proxy = new WebProxy("http://64.202.165.130:3128/", true)
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Do something with the response...

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.