How can I return a HTTP 401 from a WCF service?
If you are programming a REST-service it can be done this way:
private IWebOperationContext context = new WebOperationContextWrapper(WebOperationContext.Current); // Get the context
context.OutgoingResponse.StatusCode = HttpStatusCode.Unauthorized; // Set the 401