PHPs htmlspecialcharacters equivalent in .NET?
Don't know if there's an exact replacement, but there is a method HtmlUtility.HtmlEncode
that replaces special characters with their HTML equivalents. A close cousin is HtmlUtility.UrlEncode
for rendering URL's. You could also use validator controls like RegularExpressionValidator
, RangeValidator
, and System.Text.RegularExpression.Regex
to make sure you're getting what you want.