I'm very new to C# and want to learn how to make HTTP requests. I want to start really simple, although that is currently evading me. I want to just perform a GET on, say, google.com. I created a command line application, and have this code. Not sure at all which usings are required.
I tested it by writing to the console, and it doesn't get past the response. Can somebody please clue me in? I'm looking to do some simple curl type stuff to test an existing API. Thank you for your help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
namespace APItest
{
class testClass
{
static void Main(string[] args)
{
string url = "http://www.google.com";
Console.WriteLine(url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.ReadKey();
}
}
}