使用 ASP.net 保存用户代理时避免 SQL 注入
我正在保存用户的浏览器用户代理以用于统计目的。
如您所知,用户代理是可以修改的。我想知道我是否应该采取措施来防止 SQL 注入。
我正在使用存储过程进行插入。
非常感谢。
I'm saving the browser user-agent of my users for stats purposes.
As you already know, user-agent can be modified. I would like to know if I should do anything to protect against SQL Injection.
I'm using Stored Procedures for inserting.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在存储过程中使用参数或使用参数使用动态 SQL。
这是来自 MSDN 的示例:
Use parameters with stored procedures or use parameters with dynamic SQL.
Here's the example from MSDN:
使用准备好的语句。确保对所有 SQL 操作使用准备好的语句,即使数据来自数据库。
Use a prepared statement. Make sure you use a prepared statement for all SQL operations, even if the data comes out of the database.