web APi unauthorized access exception code example Example: asp.net throw unauthorized exception throw new HttpResponseException(HttpStatusCode.Unauthorized);