1

I would like to point two different routes to same Get action method

 [Authorize]
 [Route("{sportType}")]
 [Route("{sportType}/{regular}")]
 public async Task<Player> Get(string sportType, string regular)
 {
  ...

Is that possible to specify something like this above? Or do I need to create a separate action?

Above code gives me the following error

 No HTTP resource was found that matches the request URI
blue piranha
  • 3,706
  • 13
  • 57
  • 98
  • Possible duplicate of [assigning-multiple-routes-to-the-same-controller-or-action-in-asp-mvc-6](https://stackoverflow.com/questions/35296018/assigning-multiple-routes-to-the-same-controller-or-action-in-asp-mvc-6) – Alok Jan 26 '18 at 17:51
  • You can do it that way as long as you configure the routes. https://stackoverflow.com/questions/34213482/multiple-routes-on-a-controller – IQtheMC Jan 26 '18 at 18:18

1 Answers1

1

Please try the following:

 [Authorize]
 [Route("{sportType}/{regular?}")]
 public async Task<Player> Get(string sportType, string regular)
 {
  ...

This may help you as well: Attribute routing

Emilio Lucas Ceroleni
  • 1,559
  • 2
  • 9
  • 13
  • Hi, with this code, when I put sporttype and regular in url, it hits the action method. But if I dont specify regular, I get the same no http resource error. The above code totally make logical sense and so I am really surprised why it couldn't be working – blue piranha Jan 26 '18 at 18:25