0

Imagine a search page with various search parameters (e.g. last name, date of birth). We used a GET-based form and everything worked fine - until now.

Last week we introduced globalization into our application and ran into problems with various fields. The HTTP-GET request is still side-effect free, however, not idempotent anymore - if the user is running under a different culture the collation changes and a different set of matched persons is returned.

Q1) Is it still a good idea to use the GET method then?

This globalization-unawareness is also "documented" in the ASP.NET MVC value binders: the QueryStringValueProvider uses CultureInfo.InvariantCulture. This provides a well-defined API to all non-UI-clients.

Without regard to question 1 we converted those forms to POST-based forms. The ASP.NET MVC FormValueProvider uses CultureInfo.CurrentCulture and model binding is back at work - without that modification we retrieved model binding errors from ASP.NET MVC.

Of course we face the problem now, that a user is not able to click the back button of his browser after searching without retrieving the annoying "are you sure that you want to POST this data again" warning.

Q2) Is there a way to tell the browser that for a page it is completely okay to post it again?

If this is not possible, we need to change back to GET-based forms, however, our URL API is not idempotent anymore...something I don't like either - AND requires me to dive deep into the ASP.NET MVC model binding infrastructure to use a culture-aware value provider...

D.R.
  • 20,268
  • 21
  • 102
  • 205
  • Surely if the user has changed their culture, then a different GET request is issued, so the idempotency of the GET is not actually in question as there are two distinct GETs? – RB. Sep 17 '13 at 14:46
  • So you would recommend to change all those forms to also send the current culture and use a model binder which is aware of that field in the query string and changes its internal culture accordingly? – D.R. Sep 17 '13 at 14:47
  • I wasn't recommending anything - I was just suggesting that your assumption that the GET request is not idempotent is not correct... – RB. Sep 17 '13 at 14:49
  • Currently it is correct...we do not send the current culture to the server. – D.R. Sep 17 '13 at 14:50

1 Answers1

0

If the request is side-effect free, it by definition is idem-potent.

You seem to confuse idempotency with "always returns the same thing".

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98