Is there a way to pass querystring parameters to an ASP.NET MVC4 Web Api controller without using the OData conventions outlined here?
http://www.asp.net/web-api/overview/web-api-routing-and-actions/paging-and-querying
I have some repository methods built using Dapper that don't support IQueryable and want to be able to manually paginate them without using the OData conventions, but whenever I try doing it the traditional ASP.NET way I get "route not found" errors.
For instance, here's a route:
context.Routes.MapHttpRoute(
name: "APIv1_api_pagination",
routeTemplate: "api/v1/{controller}/{id}",
defaults: new { area = AreaName, controller = "category", offset = 0, count = 100});
And here's the signature to match
public class CategoryController : ApiController
{
// GET /api/<controller>
public HttpResponseMessage Get(int id, int offset = 0, int count = 0)
And whenever I pass the following query:
http://localhost/api/v1/category/1?offset=10
I get the following error:
No action was found on the controller 'Category' that matches the request.
Any suggestions on how to work with querystrings sanely in ASP.NET MVC4 Web Api?