Control SQL injection in MVC

前端 未结 3 1217
情深已故
情深已故 2020-12-08 17:21

It\'s my first time developing using MVC and I want to make it secure.

When I use HtmlEncode it converts the String to the equivalent HTML String.

The user c

3条回答
  •  甜味超标
    2020-12-08 17:51

    As long as you use parameterized queries or a ORM like NHibernate or Entity Framework you don't have to do anything to prevent SQL injection. Parameters are passed to the server outside the actual SQL statement, as part of the RPC call to the server. Most ORMs use parameterized queries for performance reasones, so they are not vulnerable to SQL injection.

    SQL Injection is possible only if you create a SQL statement by concatenating string values.

    That said, you still have to be wary of user input to prevent script injection attacks. Fortunately, ASP.NET MVC already provides a request validation mechanism (see Understanding Request Validation).

提交回复
热议问题