2
I am working with SQL Server 2008 and IIS7 to host my MVC website.
For security reasons, the website on which I work at the moment does not allow strings
with special characters like '<' or '>' coming from a <textarea>
are sent to the database.
How can I encode these characters and then decode them after fetching the string from the database? I want to be able to do something like:
- Encode special characters in Razorview in a string using Javascript
- Send the encoded string (which does not have the special characters) using a POST to the Controller of MVC
- Fetch the string from the database and decode, too, in the view
The Data Anotattion
AllowHtml
prevent XSS attacks?– Marconi
He and the
[ValidateAntiForgeryToken]
.– Leonel Sanches da Silva
Got it +1. Here’s a reply interesting on the subject.
– Marconi
and this prevents code execution entered by input? (e.g. SQL Injection)
– ihavenokia
@ihavenokia If you use Entity Framework, yes.
– Leonel Sanches da Silva
yes use, thank you ;)
– ihavenokia
once I test your solution and make sure it works as expected, I will accept your answer as the most correct
– ihavenokia
If there are more questions about how to use it, just ask ;)
– Leonel Sanches da Silva