Hi
Can any one tell me why used HttpResponse class and httpRequest....?
HttpResponse
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Zoran HorvatRank #792 · 2.9K reputationPosted Aug 5, 2011, 2:41 AM EDT
After that you can inspect HTTP response status, headers and response body using HttpWebResponse.
Here is a sample code regarding these classes that I've written for another thread today:
using System.Net;
using System;
using System.IO;
namespace ExceptionTest
{
class Program
{
static void Main(string[] args)
{
try
{
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com/search?hl=en&source=hp&biw=1680&bih=917&q=search+something&oq=search+something&aq=f&aqi=g7g-v3&aql=&gs_sm=e&gs_upl=2820l4595l0l4723l16l11l0l3l3l1l231l1188l2.4.2l8l0");
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
string html = null;
if (resp.StatusCode == HttpStatusCode.OK)
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
html = reader.ReadToEnd();
}
Console.WriteLine(html);
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("Press ENTER to continue...");
Console.ReadLine();
}
}
}
The original thread is:
http://www.c-sharpcorner.com/Forums/Thread/135011/find-text-in-web-page.aspx
Zoran