Global文件的RegisterRoutes方法里加入
routes.RouteExistingFiles=false;
意思是:路由现有的文件设置为false,访问现有的文件就不经过路由了。
源代码:
publicstaticvoidRegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.RouteExistingFiles=false; routes.MapRoute( "Default",// Route name "{controller}/{action}/{id}",// URL with parameters new{ controller ="Home", action ="Index", id =UrlParameter.Optional}// Parameter defaults );
}