What's the difference between RouteCollection.Ignore(url, constraints)
and RouteCollection.IgnoreRoute(url, constraints)
?
Background
New MVC projects include this IgnoreRoute
call in Global.asax RegisterRoutes
method to skip routing for requests to .axd locations that are handled elsewhere in the ASP.NET system.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
I wanted to add an additional ignored route to a project and I started to type out the new line. After routes.I
, Intellisense pops up with .Ignore
and .IgnoreRoute
, both sounding about the same.
According to the MSDN docs, you can see that one is an instance method of the System.Web.Routing.RouteCollection
class and the other is an extension method on that class from System.Web.Mvc.RouteCollectionExtensions
.
RouteCollection.Ignore
: "Defines a URL pattern that should not be checked for matches against routes if a request URL meets the specified constraints" (MSDN docs).RouteCollection.IgnoreRoute
: "Ignores the specified URL route for the given list of the available routes and a list of constraints" (MSDN docs).
Both take a route URL pattern and a set of constraints restricting the application of the route on that URL pattern.