Reputation: 25
Need to remove the prefix from the API request
Current API path: https://localhost:7131/api/server/controller/test-api
I need to trim /api/server/ from API request before forwarding it to the specified controller.
Upvotes: -1
Views: 450
Reputation: 3495
Your question is not clear. But if you want to forward api/server/controller/test-api to controller/test-api، You can use [Route()]
in your controler
[Route("/api/server/[controller]")]
public class myController : Controller
{
[Microsoft.AspNetCore.Mvc.HttpGet("test_api")]
public IEnumerable<> test_api()
{
...
}
}
now if you call https://localhost:7131/api/server/{yourContoroler}/test-api
your test_api is called. So you can choose to be /api/server
or not
Upvotes: 1