Method with two parameters in asp.net web api

后端 未结 3 775
故里飘歌
故里飘歌 2021-02-02 10:02

How can I make a method with two parameters using ASP.NET Web Api?

So that I can call it like localhost/controller/param1/param2

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-02 10:25

    You can also call the url with specific params names in the querystring:

    /api/actions?param1=5¶m2=1/1/2000
    

    Then the controller method would be:

    GetByParams(int param1, DateTime param2)
    

提交回复
热议问题