I want my general route to determine if the query string was passed to Url like this
http://localhost/query/DailyLogs/1?dateOfLog='1/13/2013'
Here is my current route definition:
routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "query/{controller}/{id}", defaults: new { id = RouteParameter.Optional} );
I read several answers that say to add the value of dateOfLog as an optional action in the route definition:
routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "query/{controller}/{id}/{dateOfLog}", defaults: new { id = RouteParameter.Optional, dateOfLog = RouteParameter.Optional } );
It doesn't work, maybe I'm doing something wrong, I'm not sure.
This is how I handle this problem right now, but I would like to use PowerBinding Power of Engine:
var queryValue = Request.RequestUri.ParseQueryString(); string dateOfLog = queryValue["dateOfLog"];
Please tell me how to create a route definition that will use ModelBinding correctly and map your custom URL to controller parameters.
source share