Update If I use Fiddler, I see I get a 200 OK Response but the following message:
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
I have no idea where that's coming from.
Original Post
When I place a breakpoint in the web method it is never hit. The success handler runs for the ajax call. If I change the name of the url to incorrect value, I do get an error in F12 tools that it is not found.
I've tried EnablePageMethods='true'
as well on the ScriptManager
.
JavaScript lives in Scripts folder
$.ajax({
type: 'POST',
url: 'Tasks.aspx/UpdateStatus',
contentType: "application/json; charset=utf-8",
data: '{ id: 8, status: 1 }',
success: function (data) {
alert('it worked!');
},
failure: function (response) {
alert(response.d);
}
});
Tasks.aspx.cs code behind
[WebMethod(EnableSession = true)]
public static string UpdateStatus(int id, int status)
{
TaskManager taskManager = new TaskManager();
taskManager.UpdateStatus((TaskStatuses)status, id);
return string.Empty;
}