내 WebAPI에서 잘못된 인증을 발견하면 다음을 사용합니다.WebAPI에서 401 Unerautized 반환
[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);
}
}
실제로 302 발견 응답을 수신하고 401 인증을받지 않았습니다.
그래서 내가 뭘 잘못하고 있니?
에게 반환 할 수 있습니다. – Matt
비슷한 코드를 사용하면 http 401을 반환합니다. [전역 필터 또는 OWIN 세부 정보]를 사용하지 않는지 확인하십시오 (http://stackoverflow.com/questions/20149750/owin-unauthorised-webapi-call- login-page-401보다는 오히려 -return-login-controller 메소드라고 불리는 다른 목적을 위해). 간단한 빈 프로젝트를 시도해보십시오. 프로젝트 설정과 관련이 있는지 확인하십시오. – bsoulier