以下是我的 JS 代码
$("#submitPassword").click(function () {
$.ajax({
type: "POST",
url: "@Url.Action("IsUserExist","Register")",
data: { emailOrPhone: $("#emailOrPhone").val(), password: $("#password").val() },
success:function(response){
if (response) {
alert("User Exist");
}
else alert("Doesn't exist");
}
});
});
以下是控制器端代码
public bool IsUserExist(string emailOrPhone,string password)
{
DBEntities db = new DBEntities();
var q = from profile in db.Profiles
where profile.Email == emailOrPhone && profile.Password == password
select profile;
if (q == null)
return false;
else
return true;
}
我的程序总是显示一个警告框,即“用户存在”,即使我输入了错误的密码。请告诉我什么问题