如何设置路由,让访问如下效果
http://localhost:16101/Home/Index
http://localhost:16101
 
http://localhost:16101/items/index?categoryenname=movie
http://localhost:16101/movie
 
http://localhost:16101/items/index?categoryenname=movie&typeenname=love
http://localhost:16101/movie/love

解决方案 »

  1.   

    后面两个可能还要考虑querystring参数前后不同吧.不如在items页面判断了做跳转.
      

  2.   

    你好,能具体说说怎么在items页面判断了做跳转吗
      

  3.   

    请大家给看看这么写为什么会有这么个情况:
       进首页(Home/Index)的时候居然会执行(Items/Index),而且传的参数很奇怪,是我的图片目录 images和一个图片。categoryenname="images",typeenname="**.gif"
    routes.MapRoute(
                    "MyRoute1", // 路由名称
                       "{categoryenname}/{typeenname}", // 带有参数的 URL/{typeenname}
                     new { controller = "Items", action = "Index", categoryenname = UrlParameter.Optional, typeenname = UrlParameter.Optional }, // 参数默认值
                        new { categoryenname = @"[\s\S]+" }
                    );
                routes.MapRoute(
                    "Default", // 路由名称
                    "{controller}/{action}/{id}", // 带有参数的 URL
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
                );