ASP.NET / C# : Look for phrase using remote web request

Using ASP.NET/C#, how can I test if a remote website contains a specified phrase?  This does NOT work:
  String strResult;
  WebResponse objResponse;
  WebRequest objRequest = HttpWebRequest.Create("http://www.example.com/");
  objResponse = objRequest.GetResponse();
  using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
  {
    strResult = sr.ReadToEnd();
    Print(strResult);
    sr.Close();
  }
  if( strResult contains "illustrative examples") {
    Console.WriteLine("Phrase Found");
  }
  else {
    Console.WriteLine("Phrase Not Found");
  }

Open in new window

LVL 10
skijAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
There is no contains keyword in C#. You need to call "contains" as a method:

if( strResult.Contains("illustrative examples")) {

Open in new window


One thing to keep in mind is that some web pages add content to the view via Javascript. Your WebClient isn't going to run that Javascript when it downloads the page, so you may only be downloading part of a page. This may or may not be a factor here, but it's something to keep in mind.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.