Multiple RoutePrefixes per controller using MVC Attribute routing?

后端 未结 1 931
野趣味
野趣味 2021-01-02 19:27

With the new MVC Attribute routing, I know you can assign multiple Route attributes to a single ActionResult, but I am looking for a way to do the

1条回答
  •  醉梦人生
    2021-01-02 19:59

    Running a bunch of tests I found out that I can just add 3 Route attributes to the controller level and it works the way I want.

    Edit: a better way to do it I found was using the regex match method

    [RoutePrefix("{Type:regex(Games|Cinema|Books)}/{SectionRoute}/Character/")]

    0 讨论(0)
提交回复
热议问题