Skip to content Skip to sidebar Skip to footer

Asp.net Login Control - Protect From Sqli With Authenticate Event?

I have a quick question about the ASP.NET Login control. I understand that it protects from SQL Injection, but I was wondering if it also protects when I use the 'Authenticate' Sub

Solution 1:

SELECT * FROM aspnet_Membership AS A INNER JOIN aspnet_Users AS B ON A.UserId = B.UserId WHERE B.UserName = '" & Login1.UserName & "' AND A.Password = '" & Login1.Password & "';"

Above SQL Statement is not safe. It is prone to SQL Injection attack. You want to use parameterized query.

For example,

SELECT*FROM aspnet_Membership AS A INNERJOIN aspnet_Users AS B 
     ON A.UserId = B.UserId 
WHERE B.UserName =@UserNameAND A.Password =@Password

Post a Comment for "Asp.net Login Control - Protect From Sqli With Authenticate Event?"