Problem is you have to encode your code
using System;
using System.Net;
class Program
{
static void Main()
{
string a = WebUtility.HtmlEncode("<html><head><title>T</title></head></html>");
string b = WebUtility.HtmlDecode(a);
Console.WriteLine("After HtmlEncode: " + a);
Console.WriteLine("After HtmlDecode: " + b);
}
}
output
After HtmlEncode:
<html><head><title>T</title></head></html>
further read these articles
http://stackoverflow.com/questions/1144535/htmlencode-from-class-library
and
http://msdn.microsoft.com/en-us/library/w3te6wfz.aspx
and
http://www.dotnetperls.com/htmlencode-htmldecode