Home > Net >  Web API partially (start with) match route in Controller
Web API partially (start with) match route in Controller

Time:01-13

How can I map multiple urls to one action method? For example http://localhost:10000/api/ABC and http://localhost:10000/api/ABCDCD will map to same action name because both starts with ABC. I can't add ABC and ABCDCD as routes because I would not know in advance what user will pass.

Here is my current method

[HttpGet]
[Route("~/api/ABC/")]
public HttpResponseMessage GetData()
{
}

I tried using enter image description here

CodePudding user response:

try this

HttpGet]
[Route("~/api/ABC")]
[Route("~/api/ABCDCD")]
public HttpResponseMessage GetData()
  •  Tags:  
  • Related