23

I'm working with ASP.NET MVC and jQuery and I have a UserControl that is repeated on every page. In every page request, an AJAX callback occurs. So far so good.

But when I'm in localhost and I publish the site, I notice that this AJAX is throwing a 302 error. This only occurs on https pages, and only in FF and Chrome. On IE, the AJAX request works fine.

What is this 302 error? Why does it only occur on https pages, and only in FF and Chrome?

alex
  • 6,818
  • 9
  • 52
  • 103
André Miranda
  • 6,420
  • 20
  • 70
  • 94
  • Do you have NTLM authentication on and it's an intranet site, or one IE passes credentials to and the others wouldn't by default? – Nick Craver Jan 17 '10 at 23:21

4 Answers4

24

HTTP 302 is used for redirection. My guess is that there is some sort of server error and you are being redirected to an error page using 302. Check the server logs for errors.

Chetan S
  • 23,637
  • 2
  • 63
  • 78
  • 4
    It could happen on successful login, when server decides to redirect you to postlogin page. – mvladk Sep 02 '15 at 11:21
  • OAuth also redirects users with a 302 to the authorization server when they are attempting to retrieve a resource that requires auth to access. When this redirection is handled by a browser, a lot happens (user entering credentials, some JavaScript being executed, etc.) and the final result is usually that the resource originally desired is accessed. AJAX does none of those things, however, and you are just left with a 302. – Guillaume LaHaye Jul 21 '17 at 18:56
6

See How to manage a redirect request after a jQuery Ajax call for an in-depth discussion about the 302 issue.

EDIT:

Here are some other stackoverflow posts on the subject.

How to get jQuery.ajax response status?

Catching 302 FOUND in JavaScript

HTTP redirect: 301 (permanent) vs. 302 (temporary)

Community
  • 1
  • 1
DRaehal
  • 1,162
  • 9
  • 16
2

HTTP code 302 represents a redirection. The server is trying to tell you to redirect somewhere.

http://en.wikipedia.org/wiki/HTTP_302

Deniz Dogan
  • 25,711
  • 35
  • 110
  • 162
1

Does the server you accessing has Page Redirection facility? and that the page you access by Ajax was redirected to another page? If that is the case, you'd disable the redirection(at least ignore redirection for that page) then give it a try. PS: I think Ajax may not support url redirection.

didxga
  • 5,935
  • 4
  • 43
  • 58