1 public static void RegisterRoutes(RouteCollection routes) 2 { 3 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 4 routes.Ignore("{*allfiles}", new { allfiles = @".*.(.*)(/.*)?" }); 5 //routes.MapRoute( 6 // name: "Default", 7 // url: "{controller}/{action}/{id}", 8 // defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 9 //); 10 11 routes.MapRoute( 12 "Default", // Route name 13 "{controller}/{action}/{id}", // URL with parameters 14 new { controller = "Home", action = "Index", id = UrlParameter.Optional }, 15 new string[] { "WebApplication1.Controllers" } // Parameter defaults // Parameter defaults 16 ); 17 }
比如在mvc中使用webService 如果不添加routes.Ignore("{*allfiles}", new { allfiles = @".*.(.*)(/.*)?" });你是无法访问调用webservice中的方法的