如何设置路由,让访问如下效果
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
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
进首页(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 } // 参数默认值
);