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

后端 未结 2 1268
再見小時候
再見小時候 2020-12-03 18:12

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

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


        
2条回答
  •  情深已故
    2020-12-03 18:46

    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.

提交回复
热议问题