I have a piece of jquery that makes an ajax call to a server side webmethod
$("#Result").click(function () {
$.ajax({
type: "POST",
url: "TestPage.aspx/TestString",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// Replace the div's content with the page method's return.
$("#Result").text(msg.d);
}
});
});
This works fine if I have routing turned off
settings.AutoRedirectMode = RedirectMode.Off;
I'd like to have it on, but when I do, the ajax call fails with “401 (Unauthorized).” Is there a way I can make my ajax calls while still having routing on?
settings.AutoRedirectMode = RedirectMode.Permanent;
Edit: Some people have voted that this should be closed as a duplicate and that the answer is over here, but that answer doesn't help. The first solution it offers is to set RedirectMode to Off, which is exactly what I don't want to do, and the other bit about Friendly Urls doesn't work.