首页 新闻 会员 周边

MVC的路由设置问题

0
悬赏园豆:20 [已解决问题] 解决于 2014-01-03 16:51
routes.MapLocalizedRoute("otc",
                            "otc/{dir}/{id}.html",
                            new { controller = "Category", action = "CategoryList" },
                            new[] { "Hu.Web.Controllers" });
            routes.MapLocalizedRoute("qixie",
                            "qixie/{dir}/{id}.html",
                            new { controller = "Category", action = "CategoryList" },
                            new[] { "Hu.Web.Controllers" });
            routes.MapLocalizedRoute("bjp",
                            "bjp/{dir}/{id}.html",
                            new { controller = "Category", action = "CategoryList" },
                            new[] { "Hu.Web.Controllers" });
            routes.MapLocalizedRoute("cf",
                            "cf/{dir}/{id}.html",
                            new { controller = "Category", action = "CategoryList" },
                            new[] { "Hu.Web.Controllers" });

上边的路由能匹配前3个,最后一个怎么换位置访问都是404,

这4个路由如果换成一个

routes.MapLocalizedRoute("Categories",
                            "{category}/{dir}/{id}.html",
                            new { controller = "Category", action = "CategoryList" },
                            new[] { "Hu.Web.Controllers" });

全部路径都是404,不太清楚为什么!

如果再有分页条件什么的我得再写几个一样的路由

routes.MapLocalizedRoute("cfPage",
                            "cf/{dir}/{id}-{page}.html",
                            new { controller = "Category", action = "CategoryList" },
                            new[] { "Hu.Web.Controllers" });

有没有好的解决方案?

mvc
胡晓凯的主页 胡晓凯 | 初学一级 | 园豆:2
提问于:2014-01-03 11:45
< >
分享
最佳答案
-1

routes.MapLocalizedRoute("Categories", "{category}/{dir}/{id}.html", new { controller = "Category", action = "CategoryList" }, new[] { "Hu.Web.Controllers" });这种可以用了,是自己重写Route的时候写错路径了

胡晓凯 | 初学一级 |园豆:2 | 2014-01-03 16:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册