views:

101

answers:

1

I have a set of actions that are returning time-series data with-in ranges specifiable to the minute. They work fine with querystrings,
i.e.
/mycontroller/myaction?from=20091201 10:31&to=20091202 10:34
with or without URL encoded colons, but I thought it would be nice to have a pretty URL /mycontroller/myaction/from-20091201 10:31/to-20091202 10:34
but this now strikes fear in the hear of IIS as it doesn't like colons in the URI so I get 'Bad Request' responses.

My question then, is what's a recommended/standard course of action to ensure I can keep the time in there?

Do I need to write a custom ModelBinder to parse my own datetime format? Should the actions just take strings for from and to and parse with a custom format eg "YYYYMMDD-HHmm". Can I specify a custom format somewhere? If so where? Or should I just give this up as folly and stick with querystring parameters?

Oh, and I see a lot of people go on about RESTful URLs; from what I've read there's nothing that says query strings aren't RESTful - it's more about appropriate use of existing HTTP action types.

+2  A: 

You're right REST doesn't mean if it's its not in a folder structure its not REST.

The path structure is there to describe the resource. Querystrings can still be used to describe a filtered subset of such a resource. A date range fully qualifies as a filter criteria and should thus be perfectly RESTful being passed in as a querystring.

Martijn Laarman
Thanks Martijn, So I take it from your response that you wouldn't bother to try and cram this in the URI? I think I mostly liked that as I also have URIs for a single day and that works nicely as controller/action/20091201
lbp
Yes I would leave filter properties as request strings. Even a single day if that day is not a resource i.e think: /agenda/20091201/appointments/1 versus /cars?builtAfter=20091201.
Martijn Laarman