Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
With such a statement of the problem, it is more important for you to control the INPUT of data, and not the OUTPUT. The ASP.NET libraries, as far as I know, do not have methods like .RemovePotentialIssuesFromHtml() - define accordingly what the user can enter and what he cannot. Delete them when saving, or notify the client that he has introduced potentially dangerous constructs.
You can use the HtmlSanitizer library
https://github.com/mganss/HtmlSanitizer
It will help you remove unsafe HTML tags.
If you do not want to delete the tags entered by users, then set the AllowHtmlAttribute attribute for the field
public class BlogEntry {
public int UserId {get;set;}
[AllowHtml]
public string BlogText {get;set;}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question