HtmlEncode(string, TextWriter)

A friend pointed out the overload of HttpUtility.HtmlEncode today that I hadn't played with yet. No doubt every ASP developer has played with the version that takes in a string and returns the Html encoded string. This one will take a string and output the Html encoded text to a TextWriter, in many cases directly to the Html stream via Response.Output. So, one might use it like:

HttpUtility.HtmlEncode(BlogEntry.Text, Response.Output);

Handy.