2015-05-29

I am aware that the way that dates are dealt with in the querystring use invariant culture. however, i cannot seem to get a solution to deal with this issue to suit my needs.

I have a list of items which I filter using a posted form, the filters are wrapped in a class including various other options along with the start/end dates thus:

so the user selected their filters and clicks apply, and as the form is posted (thus adhering to my culture settings dd/MM/yyyy) the filter works fine and away they go.
however, when they click through to an item in the returned list, i am persisting the filtering in the querystring, so that they can navigate about and return with their filters still in place.
again this is working fine, until of course they filter by a date, when it gets in a kerfuffle and falls over in a heap.
In order to generate the links to navigate about I have written a helper which goes something like this:

its the urlHelper.Action which when adding in the routeValueDictionary formats the date with the month first.
I do have a custom model binder which uses my GB culture - pulled from the culture setting in the web.config - to parse any dates correctly, and also use datepickers which also use the GB format
I have done a fair bit of searching on this, and people are suggesting using ticks, or setting dates to the iso yyyy-mm-dd format.

my question is, how would I implement this? I tried changing all date formatting to use the yyyymmdd format but the url.action still decides it wants the mmddyyyy format.
I also tried wrapping the datetime filter properties with long ticks properties, but failed with that too..

if anyone can offer some assistance, it would be much appreciated

thanks

nat

Show more