Get rid of the frenzy of asp.net permissions ... This time I just can't use AJAX-CALL any web method, or I just get:
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
the code:
<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();
}
}
});
SOME MISTAKES IN SUCCESS I KNOW. THIS IS NOT A PROBLEM NOW. Firebug Console always returns 401 Unauthorized when I try to make an ajax call.
Is anyone
source
share