I can't exclude non-existing files from the routing system. I am dealing with this code in a Web Forms scenario:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.gif/{*pathInfo}");
routes.IgnoreRoute("{resource}.jpg/{*pathInfo}");
Route r = new Route("{*url}", new MyRouteHandler());
routes.Add(r);
}
When I debug
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
string path;
IHttpHandler page;
try
{
path = requestContext.RouteData.GetRequiredString("url");
LogFile(requestContext, path);
}
path still contains non existing gif files, jpg etc I want to exclude all files that have an extension if that’s possible
Is something wrong with the code above? Is the order correct, i.e. add routes.IgnoreRoute entry prior to adding a route to RouteCollections?