HttpUtility.HtmlEncode to validate user entries

会有一股神秘感。 提交于 2019-12-12 02:43:45

问题


I am trying to validate user inputs (free text) on a web page before the data is stored in the database. The site's written using unconvensional asp.net, as it was largely upgraded from classic asp.

I want to make sure / or protect users from entering text values along with invalid characters such html. At the moment, if the page is submitted it crashes.

Should I use the HttpUtility.HtmlEncode to correct each text box entry? Does this sound feasible?

Thanks in advance.


回答1:


Yes

One of the most important things you can do from a security perspective is to ensure you're encoding all types of data appropriately.

When you're storing HTML that has been put into a web form you no longer want it to be interpreted as HTML. HttpUtility.HtmlEncode ensures this happens, so yes you need to use it.



来源:https://stackoverflow.com/questions/4806834/httputility-htmlencode-to-validate-user-entries

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!