Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

302 found response

Tags:

I have implemented ajax request to populate my drop down fields. It is working Fine but when I stay idle for some time and select some value in drop down the ajax request gets 302 found response. Is it due to session out. Please let me know the solution, can we do some setting that it will never get response as 302 found.

like image 271
Aditya Avatar asked Feb 04 '12 18:02

Aditya


People also ask

What is 302 found response?

The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header.

How do you handle a 302 response?

In most cases, the browser will automatically detect this 302 Found response code, read the new Location URL, and redirect the request to that new location.

What does failed with 302 found mean?

What is an HTTP 302? The 302 status code is a redirection message that occurs when a resource or page you're attempting to load has been temporarily moved to a different location. It's usually caused by the web server and doesn't impact the user experience, as the redirect happens automatically.

Can 302 response have a body?

As far as I know, all modern browsers ignore the message body of a 302 in response to a GET or POST and will directly go to the URL as specified in Location header. Show activity on this post. A body is needed, but it can be empty.


2 Answers

The 302 status code indicates that the resource you are requesting has redirected to another resource. If this is behind some authentication, or requiring a session to be active then yes, it would follow that the session timing out is responsible for the ajax resource being called to redirect to possibly a login screen maybe.

I would seriously recommend using something like Charles or Fiddler to track the requests being made.

like image 159
Digbyswift Avatar answered Oct 11 '22 23:10

Digbyswift


In your code you should check whether a session is available, because when a GET/POST request is sent, there may be additional requests for images or other resources. Sessions won’t be available for those requests.

if (Context.Session != null)
{
    // your code
}
like image 31
Anuj Rathi Avatar answered Oct 12 '22 01:10

Anuj Rathi