3

If I have a standard AXD HttpHandler and the default ignore route for *.axd, then why is ASP.NET MVC still handling requests in subdirs, for instance if there is a request made for **/Content/Css/**css.axd?d.... If the request is made at root /css.axd?d.... everything works fine.

2
  • You might want to post your route, could be a problem with how you are defining it. Commented Nov 3, 2009 at 14:20
  • this is the default ignore route: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); Commented Nov 3, 2009 at 15:09

1 Answer 1

6

I guess the route was deliberately made like that by design, maybe because the wildcard at a start of string isn't as performant.

Unfortunately this won't work:

routes.IgnoreRoute("{ *pathAndResource }.axd/{ *pathInfo }")

The solution is to use constraints - see Phil Haack's blog post

Phil's blogs uses a regular expression constraint, but you could create you own custom contraint alternatively to make things more readable:

routes.IgnoreRoute("match axds"
 "{*url}", new { controller = "MyController", action = "MyAction" }, new
              {
                  myCustomConstraint = new FileExtensionConstraint(".axd")
              }
Sign up to request clarification or add additional context in comments.

2 Comments

Why is that default IgnoreRoute there then? In every new ASP.NET MVC projects created...
The default ignore route is needed to support asp.net 2.0's built-in web resources which are always found at: /webresource.axd see: support.microsoft.com/kb/910442.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.