ASP.NET Core Web API: Routing by method name?

前端 未结 3 1081
感动是毒
感动是毒 2021-02-15 16:25

I remember from ASP.NET Web API that it\'s sufficient to prefix Web API REST method names with HTTP commands (e.g. GetList() => HTTP GET, Delete(

3条回答
  •  一整个雨季
    2021-02-15 16:57

    You just need to add the Route to the top of your controller.

    Specify the route with api, controller and action:

    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AvailableRoomsController : ControllerBase
    {
    ...
    }
    

提交回复
热议问题