title: Efficiently handle unknown controller action in MVC
body: <p>My site is facing unwanted robot call to a specific MVC controller with varying action name. It causes huge exception for hitting into nonsexist action. Our logging system almost flooded with error. </p>
  
  <p>We have decided to adopt following approach as a work around.</p>
  
  <ol>
  <li>Efficiently handle request for non-exist action so it doesn't throw exception</li>
  <li>Throttle down robot call </li>
  </ol>
  
  <p>We have written below code to achieve this. Can any one please review the approach.</p>
  
  <pre><code>protected override void HandleUnknownAction(string actionName)
  {
     if (this.ActionInvoker.InvokeAction(this.ControllerContext, 
        "ReturnErrorForUnknownAction")) return;
  }
  
  public ActionResult ReturnErrorForUnknownAction()
  {
     return Task.Delay(2000).ContinueWith(t =&gt;
     {
         return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
      }).Result;
  }
  </code></pre>
  
  <p>Above code is working fine but not sure if "<strong>ReturnErrorForUnknownAction</strong>" is a blocking call. As per my knowledge <strong>Task.Result</strong> blocks current thread.</p>
  
  <p>My original intention is to implement Asynchronous delay before sending 404 status.</p>