I am developing an application using ASP.Net Web API and to configure application routing, I'm following this method. But in my application, the url i want is the below. "http://localhost/MY/api/user/AllGridData/false/1342006446883/10/1/Id/desc"
I manually typed this url in my browser window and AllGridData method is fired. But when I access it from the application, it tries to access the url like below. "http://localhost/MY/api/user/AllGridData?_search=false&nd=1342006446883&rows=10&page=1&sidx=Id&sord=desc"
So then the AllGridData method is not fired because of the following exception. Failed to load resource: the server responded with a status of 400 (Bad Request) "http://localhost/MY/api/user/AllGridData?_search=false&nd=1342006446883&rows=10&page=1&sidx=Id&sord=desc"
My routing for this url in RouterConfig.cs is like this.
routes.MapHttpRoute(
name: "LoadGridApi",
routeTemplate: "api/{controller}/{action}/{_search}/{nd}/{rows}/{page}/{sidx}/{sord}",
defaults: new { _search = UrlParameter.Optional, nd = UrlParameter.Optional, rows = UrlParameter.Optional, page = UrlParameter.Optional, sidx = UrlParameter.Optional, sord = UrlParameter.Optional }
);
Hope you understand the problem. Ultimately what I want is to get the URL like below, so then it AllGridData method is fired. "http://localhost/MY/api/user/AllGridData/false/1342006446883/10/1/Id/desc"
What am I doing wrong? Is it because of wrong routing code?
My AllGridData method is in a WebAPI controller, not in a MVC controller.