I am trying to compare a string literal with a string downloaded from a webpage.
Here is my code.
using System;
using System.Collections.Generic;
using System.Text;
namespace testsource
{
class Program
{
static void Main(string[] args)
{
string source = getPageSource(@"http://www.mywebsite.co.uk/index.php");
string fromsource = source;
Console.WriteLine(fromsource); //Displays Text Here in console
string literal = "Text Here";
if (fromsource == literal)
{
Console.WriteLine("Match");
}
Console.ReadKey();
}
static string getPageSource(string URL)
{
System.Net.WebClient webClient = new System.Net.WebClient();
string strSource = webClient.DownloadString(URL);
webClient.Dispose();
return strSource;
}
}
}
And my webpage code is simply this.
<?php
echo 'Text Here";
?>
Thing is, it does not match.
I have a feeling its going to be something to do with encoding, which I know nothing about.
How can I overcome this hiccup?