asp.net mvc 4 - Query Case Sensitive with FirstOrDefault C# mvc4 -
I am trying to evaluate a user and password but if I use capital or lower case, then I The same result was found, the database case sensitive, but it keeps ignoring the configuration. This is my code:
public function login (model user) {bool isValid = false; Var user = db.users.FirstOrDefault (u = & gt; u.user == user.user and u.password == user.password) if (user! = Null) {isValid = true; }}
What am I doing?
Try it out: -
var query = users.FirstOrDefault ( U = & gt; u.UserName == user.UserName & String.Compare (U.Password, User Password, False) == 0);
Working.
According to OP question (for DB based): -
var query = db.Users.ToList (). Where (x => (string compar (xusername, user id, false) == 0) & amp; (string password (x password, user password, falls) == 0)) .FirstOrDefault ();
Comments
Post a Comment