What is HTTP Request ?
HTTP was meant to transfer hypertext documents.That is, it was originally intended simply to link documents together without consideration for anything like the Web-based user interfaces that are the staple of modern Web sites.
The earliest versions of HTTP supported a single GET request to fetch the named resource . It then was the server’s job to send the file as a stream of text. After the response arrived at the client’s browser, the connection terminated.
The earliest versions of HTTP supported only transfer of text streams and did not support any other sort of data transfer.
How the HTTP Request look ?
GET /aspnet4sbs/helloworld.htm HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, … , */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; … .NET CLR 3.0.04506.30)
Example of HTTP Requester :
Start Visual Studio,NET by clicking New, Project on the main menu.In the New Project dialog box, click Console Application and name the application WebRequestorApp , as shown in the following graphic:
2.Add the below references into the program.cs file .
3. Add the below code into the program.cs file.
static void Main(string args)
WebRequest req = WebRequest.Create("http://www.microsoft.com");
WebResponse resp = req.GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream(),Encoding.ASCII);
4. Run the application by clicking Debug, Start Without Debugging on the main menu.Visual Studio starts a Console for you and runs the program.After a couple of moments, you will see some HTML on your screen.
Get Free Weekly Updates
Get Weekly Email on latest blogging Tips & news from Stackbuddy.