I'm trying to set up routing for a Get
action that has an object as it's only parameter.
I have the following code:
public class LuteImage
{
public string Id { get; set; }
public string Dimensions { get; set; }
public string Quality { get; set; }
}
public class ImageController : ApiController
{
public HttpResponseMessage Get(LuteImage luteImage)
{
}
}
In my WebApiConfig.cs
file I have the following route before the default route
config.Routes.MapHttpRoute(
name: "ImageOptions",
routeTemplate: "api/image/{id}/{dimensions}/{quality}",
defaults: new {
controller = "image",
dimensions = RouteParameter.Optional,
quality = RouteParameter.Optional,
}
);
However, when I navigate to localhost:xxx/api/image/123/300x300/b
, the luteImage
property is just null
.
How do I allow the luteImage
object to take the parameters?