asp.net Mvc 访问静态页面

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
            );

        }

posted @ 2012-10-30 11:48  Raywang80s  阅读(252)  评论(0编辑  收藏  举报