How to get GET parameters with ASP.NET MVC ApiController

后端 未结 8 1354
挽巷
挽巷 2021-01-07 16:54

I feel a bit absurd asking this but I can\'t find a way to get parameters for a get request at /api/foo?sort=name for instance.

In the ApiControll

8条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 17:25

    Adding a default value does the job:

    public string Get(string sort="")
    

提交回复
热议问题