asp.net mvc 静态文件目录中针对个别目录做路由设置
坑点:这个路由配置是有顺序的,顺序不对各种不生效;反而变量名'var'是没有特定要求名字自己取的;
public static void RegisterRoutes(RouteCollection routes) { routes.RouteExistingFiles = true; routes.IgnoreRoute("Images/{*var}"); routes.IgnoreRoute("Scripts/{*var}"); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }); routes.MapRoute("imgs", "imgs/{*var}", new { controller = "imgs", action = "Index" }); }