这是我的问题,我有一段WCF REST代码,如果在这种情况下找不到图像的请求对象,则按照建议返回NULL。 这是我的代码
if (imageStream == null) {
WebOperationContext.Current.OutgoingResponse.SetStatusAsNotFound("Image not available for the requested size.");
return null;
}
这在 GET 中按预期发送 404 错误,但对于 HEAD 发送 500 内部服务器错误
有什么想法吗?
尝试使用 throw new WebFaultException(HttpStatusCode.NotFound);
以下是有关 WebFaultException 的更多信息