3
生病用asp.net许可疯狂... 这个时候,我只是不能AJAX-CALL任何种类的WebMethod,或者我只是得到:ASP.NET WEBMETHOD总是返回401
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
代码:
<WebMethod(True)> _
Public Function Login(ByVal usuario As String, ByVal senha As String) As Boolean
[lots of validations]
If (con.Connection.State = ConnectionState.Open) Then
Return True
Else
Return False
End If
End Function
JQUERY CALL:
$("#btnEnviar").click(function() {
$('#login').hide();
$('#ajaxLoader').fadeIn();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Login.aspx/Login",
data: "{'usuario':'" + $('#txtUsuario').val() + "','senha':'" + $('#txtSenha').val() + "'}",
dataType: "json",
dataFilter: function(data) {
var msg = eval('(' + data + ')');
if (msg.hasOwnProperty('d'))
return msg.d;
else
return msg;
},
success: function(msg) {
if (msg.UsuarioValido == '1') {
top.location = "Home.aspx"
}
else {
$('#ajaxLoader').hide();
$('#login').fadeIn();
}
}
});
上有一些错误我知道成功的东西。这不是现在的问题。 Firebug控制台总是返回401未授权当我尝试ajax调用。
有人吗?
你是如何做的电话吗? – 2010-07-05 23:26:56
编辑了主帖。 – ale 2010-07-05 23:31:23
你在web配置中设置了什么认证? – redsquare 2010-07-05 23:32:35