基本原则:精确匹配的靠前;缩略路径靠后。


具体来说:

 routes.MapRoute(
                            "PhotoDetail", // Route name
                            "Photos/Detail/{albumId}/{photoId}/{commentPageIndex}", // URL with parameters
                            new { controller = "Photos", action = "Detail", albumId = UrlParameter.Optional, photoId = UrlParameter.Optional, commentPageIndex=UrlParameter.Optional } // Parameter defaults
                        );
要靠前;

 

routes.MapRoute(
                            "PhotoDetailShort", // Route name
                            "Photos/{albumId}/{photoId}/{commentPageIndex}", // URL with parameters
                            new { controller = "Photos", action = "Detail", albumId = UrlParameter.Optional, photoId = UrlParameter.Optional, commentPageIndex = UrlParameter.Optional } // Parameter defaults
                        );
要放到后面

否则可能很诡异的事情出现。

相关文章:

  • 2021-09-10
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2021-07-16
  • 2021-09-03
  • 2022-02-13
  • 2022-12-23
相关资源
相似解决方案