How would you pass through ">=" in the querystring?
I would like to pass some operators through as querystring parameters so that I can convert them, along with a value into an SQL query. The idea would be to let the querystring parameters dictate wether the page returns search results where prices are equal to, greater than or equal to, greater than, less than or less than or equal to as follows:
=, >=, >, < and <=
I'm not sure what the best practise is for passing these operators through is, could an开发者_JS百科ybody help me out? Would you pass through ascii codes or simply text like e, gte, gt, lt, lte and then convert them on results page that builds the query?
Thanks guys!
As user Kon said, use HttpServerUtility.UrlEncode
. I've once written a tiny little class to simplify working with query strings so that I do not have to call Server.UrlEncode.
As a side note, keep an eye on SQL injection aka Little Bobby Tables:
(Source)Server.UrlEncode
You can use eq, ne, gt, lt, ge, le, sa, eb, ap like in the examples below
ge means >=
GET [base]/subjects?grade=ge90
le means <=
GET [base]/encounter?length=le20
More information you can find on those websites: https://www.hl7.org/fhir/stu3/search.html#number https://www.hl7.org/fhir/stu3/search.html#prefix
URL encoding is definitely what you're looking for. Take a look at the Web.Utils namespace. http://msdn.microsoft.com/en-us/library/system.web.util.httpencoder.aspx
精彩评论