Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Differentiate Route Based On QueryString in Web API

$
0
0

I have an ApiController where I have 2 actions:

public IEnumerable<Users> GetUsers(){}

public IHttpActionResult UsersPagination(int startindex = 0, int size = 5, string sortby = "Username", string order = "DESC"){}

Since I have default routing like below:

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

I get the error:

Multiple actions were found that match the request: 
GetUsers on type HomeBook.API.Controllers.UsersController 
UsersPagination on type HomeBook.API.Controllers.UsersController

Basically, I want 2 actions in my controller: one that returns all users another returns a pagination form of users. Like here: http://dev.librato.com/v1/pagination

Please suggest how I can achieve this.


Viewing all articles
Browse latest Browse all 4850


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>