title: ASP.NET MVC IgnoreRoute method doesn't work correctly when URL starts with "/Views/"
body: <p>I use ASP.NET MVC in my application.<br>
  Users can specify their own images, styles, scripts by including them on the page.<br>
  But when they specify URL to the file which not exists then routing mechanism tries to find controller and action by URL to image or styles etc.</p>
  
  <p>I've added a method IgnoreRoute and specified there all extensions I don't want to handle by routing.</p>
  
  <p>It works correctly until URL doesn't starts with "Views/...".<br>
  In this case URL passes into application and executes error 404 inside of application.<br>
  But I want to handle this error with IIS.</p>
  
  <p>This can be tested with empty project.
  You can simply use this code for Global.asax.cs file:</p>
  
  <pre><code>
  using System;
  using System.Web.Mvc;
  using System.Web.Routing;
  
  namespace MvcApplication1
  {
      public class MvcApplication : System.Web.HttpApplication
      {
          public static void RegisterRoutes(RouteCollection routes)
          {
              routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
              routes.IgnoreRoute(
                  "{*staticfile}",
                  new { staticfile = @".*\.(jpg|gif|jpeg|png|js|css|htm|html|htc)$" }
              );
  
              routes.MapRoute(
                  "Default",                                              // Route name
                  "{controller}/{action}/{id}",                           // URL with parameters
                  new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
              );
  
          }
  
          protected void Application_Start()
          {
              RegisterRoutes(RouteTable.Routes);
          }
  
          void Application_Error(object sender, EventArgs e)
          {
  
          }
      }
  }
  </code>
  </pre>
  
  <p>Now we need to host this application at IIS, for example at <a href="http://localhost/testmvc/" rel="nofollow noreferrer">http://localhost/testmvc/</a> </p>
  
  <p>You can place a break-point inside of Application_Error method to see when error executes inside of application</p>
  
  <p>So now open test URL:
  <a href="http://localhost/testmvc/test.css" rel="nofollow noreferrer">http://localhost/testmvc/test.css</a><br>
  We can see that IIS handled that error:
  <img src="https://i.stack.imgur.com/27tge.png" alt="enter image description here"></p>
  
  <p>Now we open another test URL with "/Views/..." in the path:
  <a href="http://localhost/testmvc/Views/test.css" rel="nofollow noreferrer">http://localhost/testmvc/Views/test.css</a><br>
  And we see that error was handled by ASP.NET:
  <img src="https://i.stack.imgur.com/EuMLf.png" alt="enter image description here"></p>
  
  <p>So the question is: maybe there exists some setting to tell MVC to not handle URL with "Views" in the path?</p>