解决XSS漏洞问题C#

时间:2016-12-28 05:54:09

标签: c# xss fortify

LabelWarning.Text += "<li>Fund: " + dr["CltAcctNo"].ToString() + ", Security: "
                            + dr["SecFullName"].ToString() + ", Expected holdings: " + share.formatQty(dr["ExpHoldings"].ToString(), dr["DecPlaces"].ToString())
                            + ", Calculated holdings: " + share.formatQty(dr["CalHoldings"].ToString(), dr["DecPlaces"].ToString()) + "</li>";

由于XSS(跨站脚本)导致此代码出现问题,是否有解决此问题的想法?

1 个答案:

答案 0 :(得分:0)

你也可以在搜索引擎上找到这个答案:

LabelWarning.Text += "<li>Fund: " + System.Web.HttpUtility.HtmlEncode(dr["CltAcctNo"].ToString()) + ", Security: "
                        + System.Web.HttpUtility.HtmlEncode(dr["SecFullName"].ToString()) + ", Expected holdings: " + System.Web.HttpUtility.HtmlEncode(share.formatQty(dr["ExpHoldings"].ToString(), dr["DecPlaces"].ToString()))
                        + ", Calculated holdings: " + System.Web.HttpUtility.HtmlEncode(share.formatQty(dr["CalHoldings"].ToString(), dr["DecPlaces"].ToString())) + "</li>";