The SharePoint Code Analysis Framework rule SPC020220: Do not call 'HttpUtility.HtmlEncode' states that:
The assembly should not call
HttpUtility.HtmlEncode(string)
to encode strings [and that]SPHttpUtility.HtmlEncode
[should be used] instead.
I don't understand the rationale. If I understand correctly, both methods perform the same thing. According to MSDN:
The
HtmlEncode
method replaces ampersand, double-quotation, single-quotation, less-than, and greater-than characters with the appropriate entity references.
So does HttpUtility.HtmlEncode(string)
.
Why preferring the first to the second?
What is a case where two methods will perform differently?