Getting sick with asp.net permission madness... This time, I Just cant AJAX-CALL any kind of webmethod or i just get:
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
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();
}
}
});
THERE ARE SOME MISTAKES ON THE SUCCESS STUFF I KNOW. THATS NOT THE PROBLEM FOR NOW. Firebug Console always return 401 Unauthorized when i Try an ajax call.
Anyone?