HTTP not found custom exception in asp.net web API
<p>I'm using this code source from <a href="https://dzone.com/articles/handling-http-404-error-aspnet" rel="nofollow noreferrer">here</a> to display the custom 404 with detailed error message in my application. 
But the ActionSelector does not work and throw the null exception in <strong>request</strong></p>

<pre><code>public class HttpNotFoundAwareControllerActionSelector : ApiControllerActionSelector
    {
        public HttpNotFoundAwareControllerActionSelector()
        {
        }

        public override HttpActionDescriptor SelectAction(HttpControllerContext controllerContext)
        {
            HttpActionDescriptor decriptor = null;
            try
            {
                decriptor = base.SelectAction(controllerContext);
            }
            catch (HttpResponseException ex)
            {
                var code = ex.Response.StatusCode;
                if (code != HttpStatusCode.NotFound &amp;&amp; code != HttpStatusCode.MethodNotAllowed)
                    throw;
                var routeData = controllerContext.RouteData;
                routeData.Values["action"] = "Handle404";
                IHttpController httpController = new ErrorController();
                controllerContext.Controller = httpController;
                controllerContext.ControllerDescriptor = new HttpControllerDescriptor(controllerContext.Configuration, "Error", httpController.GetType());
                decriptor = base.SelectAction(controllerContext);
            }
            return decriptor;
        }
    }
</code></pre>

<p>This is my HttpError controller</p>

<pre><code>public class ErrorController : ApiController
    {
        [HttpGet, HttpPost, HttpPut, HttpDelete, HttpHead, HttpOptions, AcceptVerbs("PATCH")]
        public HttpResponseMessage Handle404()
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.NotFound, Logger.ConditionWarning("Invalid API Request - 404 Not Found"));
            return response;
        }
    }
</code></pre>

<p>It seems that SelectAction not forwarding the request to controller? Please help</p>

<p><a href="https://i.stack.imgur.com/Jf6RW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jf6RW.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/5yKVt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5yKVt.png" alt="enter image description here"></a></p>