I have an AJAX function inside of my _Layout.cshtml partial view that's used by all views that posts to SignIn(). If the login is unsuccessful, it is supposed to redirect to SignInFailed() and simply return the view. Instead, after returning the view, it is redirecting back to the original view.
I am not receiving any kind of exceptions or errors that would prevent it from remaining in SignInFailed().
Here is my AJAX:
$.ajax({
type: "POST",
traditional: true,
url: "@Url.Action("SignIn", "Home")",
data: { user: name, password: code, pageName: urlPage },
success: function () {
///do stuff
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
if (debug) {
alert(XMLHttpRequest.responseText);
alert(textStatus);
alert(errorThrown);
}
}
});
Why is it redirecting back to the original view when there is no instruction to do so and what can I do to prevent this behavior?
return RedirectToActionwill it still remain on the same page?JsonResultindicating success or otherwise, and based on that, uselocation.href = someUrl;in the success callback to redirect.