title: How can I properly handle 404 in ASP.NET MVC?
body: <p>I am using RC2</p>
  
  <p><strong>Using URL Routing:</strong> </p>
  
  <pre><code>routes.MapRoute(
      "Error",
       "{*url}",
       new { controller = "Errors", action = "NotFound" }  // 404s
  );
  </code></pre>
  
  <p>The above seems to take care of requests like this (assuming default route tables setup by initial MVC project): "/blah/blah/blah/blah"</p>
  
  <p><strong>Overriding HandleUnknownAction() in the controller itself:</strong></p>
  
  <pre><code>// 404s - handle here (bad action requested
  protected override void HandleUnknownAction(string actionName) {
      ViewData["actionName"] = actionName;
      View("NotFound").ExecuteResult(this.ControllerContext);
  }  
  </code></pre>
  
  <p>However the previous strategies do not handle a request to a Bad/Unknown controller.  For example, I do not have a "/IDoNotExist", if I request this I get the generic 404 page from the web server and not my 404 if I use routing + override.  </p>
  
  <p>So finally, my question is:  <em>Is there any way to catch this type of request using a route or something else in the MVC framework itself?</em>  </p>
  
  <p>OR should I just default to using Web.Config customErrors as my 404 handler and forget all this?  I assume if I go with customErrors I'll have to store the generic 404 page outside of /Views due to the Web.Config restrictions on direct access.</p>