• 0

ASP .NET equivalent of PHP's cURL


Question

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)?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

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...

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.