To HTMLENCODE or not to HTMLENCODE user input on web form (asp.net vb)
问题 I have many params making up an insert form for example: x.Parameters.AddWithValue("@city", City.Text) I had a failed xss attack on the site this morning, so I am trying to beef up security measures anyway.... Should I be adding my input params like this? x.Parameters.AddWithValue("@city", HttpUtility.HtmlEncode(City.Text)) Is there anything else I should consider to avoid attacks? 回答1: Don't encode input. Do encode output. At some point in the future, you might decide you want to use the