In my WebAPI, if I detect a Bad Authorisation I use the following;
[HttpPost]
public HttpResponseMessage CustomerQuotationComplete(Guid apiKey, int EnquiryId, int SiteId, bool accepted)
{
if (IsRequestAuthorized())
{
...
}
else
{
var msg = new HttpResponseMessage(HttpStatusCode.Unauthorized) { ReasonPhrase = "Bad Authentication" };
throw new HttpResponseException(msg);
}
}
However what I am actually receiving a 302 Found response, not a 401 Unauthorized.
So what am I doing wrong?