HttpHandlers with ASP.NET MVC

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

+3
source share
1 answer

I assume that the route was intentionally designed in the same way by design, perhaps because the wildcard at the beginning of the line is not so efficient.

Unfortunately this will not work:

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

The solution is to use restrictions - see Phil Haack on the blog

Phil , , :

routes.IgnoreRoute("match axds"
 "{*url}", new { controller = "MyController", action = "MyAction" }, new
              {
                  myCustomConstraint = new FileExtensionConstraint(".axd")
              }
+6

Source: https://habr.com/ru/post/1721767/


All Articles