asp.net Mvc 访问静态页面

xiaoxiao2021-02-28  68

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

        }

转载请注明原文地址: https://www.6miu.com/read-23595.html

最新回复(0)