Resolving XSS vulnerability issue C#

249 views Asked by At
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>";

Having an issue from this code due to XSS (Cross site scripting), any idea to resolve this issue?

1

There are 1 answers

0
NETDev On

you could also simply find this answer on search engines:

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>";