user1774333
user1774333

Reputation: 41

Best way to Sanitize user input

What is the best way to sanitize input in asp.net application using whitelisting of characters?

Upvotes: 2

Views: 2559

Answers (1)

Ted Krapf
Ted Krapf

Reputation: 463

A starting point / good practice:

HtmlEncode will handle converting all the html tags to harmless values like: <

Always use SQL parameters instead of string concatenation to avoid SQL injection. (Entity Framework or LINQ does this for you)

I was always taught: don't try to reinvent the wheel with fundamentals (e.g. building your own sanitization solution), but stand on the shoulders of giants. Smarter minds than me develop toolboxes for input sanitization, cryptography, random generators. Writing one myself has a high likelihood of being error prone.

Upvotes: 3

Related Questions