2012-08-10 3 views
0

여기 내 문제입니다.이 경우 요청한 개체가 발견되지 않으면 제안 된대로 NULL을 반환하는 WCF REST 코드 조각이 있습니다. 여기에 내 코드REST WCF 서비스가 404 대신 HEAD에서 오류 500을 보내고 있습니다.

if (imageStream == null) { 
WebOperationContext.Current.OutgoingResponse.SetStatusAsNotFound("Image not available for the requested size."); 
return null; 
} 

GET에서 예상대로이 404 오류를 보내고이지만, HEAD 500 내부 서버 오류

어떤 아이디어를 보내는?

답변

0

에 한번 사용 여기 throw new WebFaultException(HttpStatusCode.NotFound); 내가 그 명령으로 노력하고 내가 를 찾을 수 없습니다 반환하려면 표시 할 때 여전히 심지어 500 내부 서버 오류를 보여주는 것보다

+0

WebFaultException에 대해 경우 (같이 ImageStream == NULL) { WebOperationContext입니다 .Current.OutgoingResponse.SetStatusAsNotFound ("요청한 크기로 이미지를 사용할 수 없습니다."); WebOperationContext.Current.OutgoingResponse.ContentLength = 0; WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; 새 WebFaultException을 throw합니다 (HttpStatusCode.NotFound); } –

관련 문제