MVC利用URLRoute实现伪静态

时间:2023-05-09 18:59:20

routes.MapRoute(
                    "Default", // Route name
                    "{controller}/{action}.html", // URL with parameters
                    new { controller = "Portal", action = "Index", id = UrlParameter.Optional }
                    ); //首页伪静态
            routes.MapRoute(
                    "ArticleList", // Route name
                    "{controller}/{action}/{typeId}.html", // URL with parameters
                    new { controller = "Article", action = "List", typeId = UrlParameter.Optional }
                    ); // 文章类型列表伪静态
            routes.MapRoute(
                    "ArticleDetail", // Route name
                    "{controller}/{action}/{id}.html", // URL with parameters
                    new { controller = "Article", action = "Detail",id = UrlParameter.Optional }
                    ); // 文章详情页伪静态
            routes.MapRoute(
                    "JobList", // Route name
                    "{controller}/{action}/{id}.html", // URL with parameters
                    new { controller = "Job", action = "Detail", id = UrlParameter.Optional }
                    ); // TODO
            routes.MapRoute(
                    "JobDetail", // Route name
                    "{controller}/{action}/{id}.html", // URL with parameters
                    new { controller = "Article", action = "Detail", id = UrlParameter.Optional }
                    ); // TODO