public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Ignore("{*allfiles}", new { allfiles = @".*\.(.*)(/.*)?" });
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
//); routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "WebApplication1.Controllers" } // Parameter defaults // Parameter defaults
);
}
比如在mvc中使用webService 如果不添加routes.Ignore("{*allfiles}", new { allfiles = @".*\.(.*)(/.*)?" });你是无法访问调用webservice中的方法的