I am a member of the Fortify Security Research Group and I regret the confusion caused by this issue. We did not deal very well with this issue. I think that part of the problem is the name of the category - we are not trying to say that there is something wrong with the check mechanism, we just can’t say whether this is a suitable check for this situation.
In other words, we don’t know what the correct check is for your specific context. For this reason, we don’t recognize any HTML encoding features, as we test XSS out of the box, even those contained in the Microsoft AntiXSS library.
As for the correct solution, if you use HtmlEncode to output the username to the body of the HTML page, your source code is fine. If the encoded username is used in the URL, it may be vulnerable to XSS. In Fortify, when we find similar problems in our own code, if the check matches the context, we mark it “Not a problem”.
We are aware that the problems associated with these problems are constantly improving our rules to make them more accurate and understandable. We release new rules every three months and expect to make a couple of changes to upcoming releases. For Q4, we plan to divide the problems into inadequate verification (for coding a blacklist and other weak verification schemes) and Context Sensitive Validation (the type of problem you see). Please let us know if we can help more.
(link to an explanation of OWASP why HTML encoding does not solve all problems: http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Why_Can.27t_I_Just_HTML_Entity_Encode_Untrusted_Data.3F )
source share