how to avoid SQL Injection with Linq with EF in codefirst technique in c#

☆樱花仙子☆ 提交于 2019-12-06 12:29:13

As long as your are building your queries through LINQ, then you are not vulnerable to SQL injection. While this doesn't mean that your code is invulnerable to ALL sorts of attacks (brute forcing passwords, etc.), you won't be vulnerable to SQL injection.

Dynamic LINQ automatically protects against a SQL injection attack, even if you build up your arguments using Request.QueryString etc.

You can add your own layer of very basic checking by making sure that no input strings contain the ";" character, which is typically used in SQL injection to allow entering custom SQL queries.

See also http://www.codeproject.com/KB/database/SqlInjectionAttacks.aspx.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!