[ACCEPTED]-How to ignore route in asp.net forms url routing-ignoreroute

Accepted answer
Score: 40

You don't need to reference ASP.NET MVC. You 5 can use the StopRoutingHandler which implements IRouteHandler 4 like so:

routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));

This is part of .NET 3.5 SP1 and 3 doesn't require MVC. The IgnoreRoutes method 2 is a convenience extension method which 1 is part of ASP.NET MVC.

Score: 8

An old question but in case it still helps 6 anyone, this worked for me:


The "Ignore" method 5 exists, whereas in standard ASP.NET the 4 "IgnoreRoute" method appears not to (i.e., not 3 using MVC). This will achieve the same 2 result as Haacked's code, but is slightly 1 cleaner ...

Score: 3

I would just like to add that you also need 4 to make sure the order of your IgnoreRoutes 3 rule is in the the correct order otherwise 2 your first route will be applied first and 1 your IgnoreRoute will... well be ignored.

Score: 1

MapRoute and IgnoreRoute are extension methods 2 in System.Web.Mvc --- do you have that assembly 1 referenced properly?

More Related questions