.Net Method for converting String to HTML Escape Characters

Damien picture Damien · Jan 20, 2010 · Viewed 7.5k times · Source

I want to convert an e-mail address into HTML Escape Characters as a basic way to try and avoid being harvested by spam-bots. Like mentioned in this question:

When placing email addresses on a webpage do you place them as text like this:

[email protected]

or use a clever trick to try and fool the email address harvester bots? For example:

HTML Escape Characters:

joe.somebody@company.com

I cannot find a .Net method to do so though. The Html.Encode only does the invalid HTML characters such as £$%^& and not letters.

Does a method exist or do I need to write my own?

Many Thanks

Answer

Philipp Grathwohl picture Philipp Grathwohl · Jan 20, 2010

I think you can use

HttpUtility.HtmlEncode

also see here: http://msdn.microsoft.com/en-us/library/73z22y6h.aspx