How to get GET parameters with ASP.NET MVC ApiController

后端 未结 8 1429
挽巷
挽巷 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:26

    You can also use the following

    var value = request.GetQueryNameValuePairs().Where(m => m.Key == "paramName").SingleOrDefault().Value;
    

提交回复
热议问题