Check script in asp.net text box

We would like to prevent users from entering html or javascript in the text box.

We can simply analyze the input and check the angel brackets. I wonder if there is a better way to do this?

+5
source share
5 answers

I found that replacing angel brackets with encoded angel brackets solves most of the problems. Here is a link for all the ways people can cross site script. Creating a regular expression to stop every taste of HTML and Script is almost impossible.

+5
source

If you set Page.ValidateRequest = true, then this will stop this.

.net 1.1 ( ) true.

+3

?

+2

I came across this html utility. The code uses a white list of tags that are allowed for input. The script then formats the input text and removes tags and scripts that can be used to attack using cross-site scripting.

For your purposes, you cannot have any tags in the white list.

Html utilty

0
source

All Articles