C# 使用web服务使用jquery检查用户名或密码是否为true或false
这是我的C代码 这是我的aspx页面C# 使用web服务使用jquery检查用户名或密码是否为true或false,c#,jquery,sql-server,web-services,C#,Jquery,Sql Server,Web Services,这是我的C代码 这是我的aspx页面 <script> $(document).ready(function () { $('#btnLogin').click(login); }); function login() { var kullaniciAd = $('#userName').val(); var sifre = $('#password').val(); $.ajax({
<script>
$(document).ready(function () {
$('#btnLogin').click(login);
});
function login() {
var kullaniciAd = $('#userName').val();
var sifre = $('#password').val();
$.ajax({
url: "http://localhost:63000/LoginService.asmx/Login",
type: "POST", //or should it be GET?
dataType: "json",
data: JSON.stringify({ kullaniciAd: kullaniciAd, sifre: sifre }),
contentType: "application/json; charset=windows-1254",
success: function () {
alert("");// i have an alert div down there how can i show if login is successful or not in that alert div
},
error: function (e) {
alert(e.statusText);
}
})
}
</script>
<%--<div class="alert alert-danger alert-dismissable">
<button contenteditable="false" type="button" class="close" data-dismiss="alert"
aria-hidden="true">
×</button>
<strong>Well done!</strong>You successfully read this important alert message.
</div>--%>
$(文档).ready(函数(){
$('#btnLogin')。单击(登录);
});
函数登录(){
var kullaniciAd=$('#userName').val();
var sifre=$('#password').val();
$.ajax({
url:“http://localhost:63000/LoginService.asmx/Login",
键入:“POST”,//还是应该获取?
数据类型:“json”,
数据:JSON.stringify({kullaniciAd:kullaniciAd,sifre:sifre}),
contentType:“应用程序/json;字符集=windows-1254”,
成功:函数(){
alert(“”;//下面有一个alert div,如何在该alert div中显示登录是否成功
},
错误:函数(e){
警报(如状态文本);
}
})
}
这看起来很简单,但我无法决定是否在web服务中检查true或false,只发送jquery一个数据(true,false),或者使用调用true或false web方法在jquery中检查true或false???这是我第一次看到检查是否有用户与输入的密码匹配的登录逻辑。我的建议。。不要 更好的方法是检查具有给定userid的用户是否存在,然后从数据存储返回存储的密码(和salt)。下一步是对输入的普通密码进行散列,并使用存储的值进行检查。这给了你三种可能的结果
- 已知用户,但输入的密码不正确
- 找不到用户(sql查询返回0个结果)
- 已找到用户,密码正确
这是我第一次看到检查是否有用户与输入的密码匹配的登录逻辑。我的建议。。不要 更好的方法是检查具有给定userid的用户是否存在,然后从数据存储返回存储的密码(和salt)。下一步是对输入的普通密码进行散列,并使用存储的值进行检查。这给了你三种可能的结果
- 已知用户,但输入的密码不正确
- 找不到用户(sql查询返回0个结果)
- 已找到用户,密码正确
<script>
$(document).ready(function () {
$('#btnLogin').click(login);
});
function login() {
var kullaniciAd = $('#userName').val();
var sifre = $('#password').val();
$.ajax({
url: "http://localhost:63000/LoginService.asmx/Login",
type: "POST", //or should it be GET?
dataType: "json",
data: JSON.stringify({ kullaniciAd: kullaniciAd, sifre: sifre }),
contentType: "application/json; charset=windows-1254",
success: function () {
alert("");// i have an alert div down there how can i show if login is successful or not in that alert div
},
error: function (e) {
alert(e.statusText);
}
})
}
</script>
<%--<div class="alert alert-danger alert-dismissable">
<button contenteditable="false" type="button" class="close" data-dismiss="alert"
aria-hidden="true">
×</button>
<strong>Well done!</strong>You successfully read this important alert message.
</div>--%>