throw new WebFaultException(System.Net.HttpStatusCode.Unauthorized);
Notes: "MSDN: when using a WCF REST endpoint (WebHttpBinding and WebHttpBehavior or WebScriptEnablingBehavior), the HTTP status code in the response is set accordingly. However, WebFaultException can be used with endpoints without REST and behaves like a regular FaultException."
source share