Question

I am trying to throw an HttpResponseException(HttpStatusCode.NotFound) and I am getting the following error

The response message returned by the Response property of this exception should be immediately returned to the client. No further handling of the request message is required.

I have removed all of the code in my method and I am just throwing the exception like this

[WebGet]
public MyData Get()
{
    throw new HttpResponseException(HttpStatusCode.NotFound);
}

If I change my method to return a HttpResponseMessage I can get it to work correctly, however it does not solve the issue and I am unable to get my authentication operation handler to work without being able to throw a HttpResponseException.

Was it helpful?

Solution

Try using a WebFaultException for returning HTTP Status codes in WCF...

throw new WebFaultException(HttpStatusCode.NotFound);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top