How to ignore a route inside an area?
I have captcha in my MVC application.It loads its image from an GenericHanlder(.ashx),so if imnot using areas it works fine, if I just ignore routes from that URL.
i.e: In Global.asax
routes.IgnoreRoute(Counts/{filename}.{ashx}/{*pathinfo});//Counts is the controller name without an area
The problem is that recently I migrated the files to a different area and the path of the route to be ignored was modified.Now its:
Admin/Acounts/Users/captcha.ashx?guid=3565465689789hfghfdf
So i try to change that path in routes.IgnoreRoutes method in Global.asax:
routes.IgnoreRoute(Admin/Acounts/Users/{filename}.ashx/{*pathinfo});
But it doesnt work anymore.Ive already try to ignore that route in RegisterArea method,in AreaRegistrationFile:
context.Routes.IgnoreRoute("Admin/Accounts/Users/{filename}.ashx/{*pathinfo}");
But that also doenst work.
Any ideas how to ignore routesto an Area?
IgnoreRoute is really just a call to Add(new Route()), with the RouteHandler parameter of the Route set to be a new StopRoutingHandler. The StopRoutingHandler tells the URL routing module to ignore the route and get whatever the next-inline HttpHandler would be.
You know that route registration is sensitive to the order of declaration. My guess is that you are declaring your IgnoreRoute after some other route already catches it.
If this bit of info doesn't help you, please post the full contents of your route registration as they will help us to give you answers.
Also, if you use the source code provided at http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx for debugging routes, it will be much easier to find the cause of your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With