asp.net Mvc 访问静态页面

来源:互联网 发布:php正则表达式 编辑:程序博客网 时间:2024/05/22 04:57
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
            );

        }

原创粉丝点击