What is the best way to issue a http get in VB.net? I want to get the result of a request like http://api.hostip.info/?ip=68.180.206.184
Try this:
WebRequest request = WebRequest.CreateDefault(RequestUrl);
request.Method = "GET";
WebResponse response;
try { response = request.GetResponse(); }
catch (WebException exc) { response = exc.Response; }
if (response == null)
throw new HttpException((int)HttpStatusCode.NotFound, "The requested url could not be found.");
using(StreamReader reader = new StreamReader(response.GetResponseStream())) {
string requestedText = reader.ReadToEnd();
// do what you want with requestedText
}
Sorry about the C#, I know you asked for VB, but I didn't have time to convert.