views:

144

answers:

0

I have a custom IErrorHandler which catches certain exceptions thrown from web services and translates them to HTTP status codes. The problem is that, even when the handler sets the status code (404 for example), the Web server (IIS 7.5) always returns 400 (Bad Request). I tried other status codes and the result is the same ("The server encountered an error processing the request. See server logs for more details.").

I tried explicity setting the status code in the ProvideFault method:

WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;

This works, but the server still returns the HTML content.

I know my handler catches exceptions (evident from debugging and logging files). BTW I'm using Windsor Castle's WCF integration. I also know IIS is not to blame, since I can explicitly set status codes in service methods, and this works OK.

I'm just trying to find out where next to look (other extension points in WCF framework) which would cause this behavior. There's obviously something in WCF (or Castle) that overrides the HTTP response before sending it back.

Thanks in advance.