Filling text fields with smaller or larger than characters (<and>)

so I ran into some problems when I show several logs that contain <and> characters in different places in different parts of my website that I am developing. Well, when I show the magazine, it works great. Of course, anytime I move, I get an error message:

A potentially dangerous Request.Form value was detected from the client ...

Now I understand this because <and> are the special html characters that I get. But is there a way to disable or somehow allow the page to display / process them? I know that I could strip these characters from wherever they might appear, but I would rather not have to.

Any suggestions?

+4
source share
4 answers

You did not send any code, so I assume you want something line by line:

 <textbox><</textbox> 

Simple, HTML encodes your content:

 <textbox>&lt;</textbox> 

You can use HttpUtility.HtmlEncode for this.

+3
source

Replace " "on" and "and" < "on" <lt "

Read this in the list of special HTML objects

+2
source

If you just want your web application to allow form input to contain potentially dangerous characters, there are several ways to do this, depending on the structure. I mainly use MVC, where you use the [ValidateInput(false)] attribute for the actions of your controller.

For WebForms, I will direct you here instead. http://msdn.microsoft.com/en-us/library/ie/bt244wbb.aspx :)

0
source

to answer your question, put ValidateRequest="false" in <%@Page ...

be careful as you are now responsible for preventing script attacks

0
source

Source: https://habr.com/ru/post/1391925/


All Articles