Getting response from a URL through HTTPRequest

Here i wrote a function which is taking URL as parameter and gets response from that URL. Check it out...

private void CallHttpWebRequest(string URL)
{

string sAddress = URL;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sAddress);
req.Accept = "text/xml,text/plain,text/html";
req.Method = "GET";
HttpWebResponse result = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
StreamReader reader = new StreamReader(ReceiveStream, System.Text.Encoding.ASCII);
string respHTML = reader.ReadToEnd();
Response.Write(
respHTML);
reader.Close();

}
Ebook Download
View all
Learn
View all