1

我有以下路线

routes.MapRoute(
    name:="Gallery",
    url:="{controller}/{action}/{*id}",
    defaults:=New With {
        .controller = "Gallery",
        .action = "Index",
        .id = UrlParameter.Optional},
    constraints:=New With {.id = ".*"}
)

我正在尝试匹配以下网址:

  • /画廊/拇指/SomeDirectory
  • /画廊/拇指/SomeDirectory/
  • /Gallery/Thumb/SomeDirectory/SomeImage.jpg

在每种情况下,我都希望使用适当的路径调用的Thumb动作。GalleryController

现在,

/Gallery/Thumb/SomeDirectory = 404.0 (Seems it doesn't match a route, passes straight through to IIS 404)
/Gallery/Thumb/SomeDirectory/ = Works
/Gallery/Thumb/SomeDirectory/SomeImage.jpg = 404.0 (Same as above)
/Gallery/Thumb/SomeDirectory/SomeImage = Works (routing works, although the path supplied in Id isn't a useful one)

我需要对我的路线做些什么才能在 id 中通过操作后传递所有内容?

4

1 回答 1

0

问题可能是您 ID 中的点,您可以对其进行 UrlEncode 吗?

于 2013-07-28T15:47:26.263 回答