I'm in charge of a Microsoft .Net WebApi that authenticates requests based on credentials sent in the request headers. If the credentials are missing or incorrect, the API returns a 401 unauthorized message. The code to do this is pretty straight forward.
if (!ValidateCredentials(Request, this.ServiceName))
{
throw new HttpResponseException(HttpStatusCode.Unauthorized);
}
This works as expected when calling the API from code in other applications (JS, C#, etc).
I recently had a 3rd party developer contact me to make calls to our API who is not primarily a Windows/.Net developer. He wanted to start by calling an API method (which is an HTTP GET method) in a browser, to make sure he got the expected 401 error. He didn't get a 401 - he got no response at all.
I did some testing and found the following:
- In Postman (without the appropriate headers), I get a 401 response and it indicates a secure connection.
- In Chrome, I get a 401 but I also got a "your connection to the site is not secure" message even though I'm using HTTPS.
- In Internet Explorer, I get a blank screen and a 401 in the developer tools, and it indicates a secure connection.
- In Firefox, I get no response. Instead the developer tools shows the request as "Blocked" (listed in the "Transferred" column).
- In Edge, the browser seems to stall out. I don't get any response, nothing even shows up as an outbound request in developer tools, and the refresh button stays perpetually as a cancel button.
Is there something wrong with how the API is responding to these requests or are they simply quirks of the respective browsers?