Too many redirects when making a call to ASP.NET Web API 2

2.4k views Asked by At

On making a POST call to a ASP.NET Web API 2 . I get the PostAUthorize_Request fired repeatedly . This results in an error . What could the problem here be ?

Failed to load resource: net::ERR_TOO_MANY_REDIRECTS [http://localhost/FT/API/V2/AuthenticateUser/validate]

enter image description here

1

There are 1 answers

0
user1429080 On

This can happen when the application is setup in a way where an original incoming request ends up in a redirect loop. One example that I have myself managed to create (and subsequently had to fix) is this:

  • The login page for the application is buggy and causes an Exception to be thrown
  • All unhandled exceptions are caught at the application level and shown through a redirect to an error page
  • But the error page itself requires you to be logged in first

When an unauthenticated request first comes in, it gets redirected to the login page, which throws an exception, causing a redirect to the error page, which requires an authenticated user so it redirects to the login page. And so on forever until the browser just stops the madness.

There are other similar redirect loops that can occur, so you need to investigate what the loop is (if indeed it is a loop). Personally I would use a third party tool like Fiddler to do this. Many other options are, I'm sure, also available.