Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net Routing: How do I ignore multiple wildcard routes?

I'd like to ignore multiple wildcard routes. With asp.net mvc preview 4, they ship with:

RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

I'd also like to add something like:

RouteTable.Routes.IgnoreRoute("Content/{*pathInfo}");

but that seems to break some of the helpers that generate urls in my program. Thoughts?

like image 667
Jim Geurts Avatar asked Aug 27 '08 14:08

Jim Geurts


1 Answers

There are two possible solutions here.

  1. Add a constraint to the ignore route to make sure that only requests that should be ignored would match that route. Kinda kludgy, but it should work.

    RouteTable.Routes.IgnoreRoute("{folder}/{*pathInfo}", new {folder="content"});
    
  2. What is in your content directory? By default, Routing does not route files that exist on disk (actually checks the VirtualPathProvider). So if you are putting static content in the Content directory, you might not need the ignore route.

like image 110
Haacked Avatar answered Oct 21 '22 22:10

Haacked