query-string

Replace item in querystring

泄露秘密 提交于 2019-12-17 20:43:40
问题 I have a URL that also might have a query string part, the query string might be empty or have multiple items. I want to replace one of the items in the query string or add it if the item doesn't already exists. I have an URI object with the complete URL. My first idea was to use regex and some string magic, that should do it. But it seems a bit shaky, perhaps the framework has some query string builder class? 回答1: Maybe you could use the System.UriBuilder class. It has a Query property. 回答2:

How do you configure Apache/PHP to accept slashes in query strings?

痞子三分冷 提交于 2019-12-17 19:47:02
问题 I have two Apache servers running PHP. One accepts forward-slashes in the query string and passes it along to PHP in the expected way, for example: http://server/index.php?url=http://foo.bar works and in PHP this expression is true: $_REQUEST['url'] == "http://foo.bar" However, in the other Apache server, the same URL results in a 403 Forbidden error! Note that if the query string is properly URL-escaped (i.e. with %2F instead of forward-slash), then everything works. Clearly there's some

Security with QueryString values in Asp.net MVC

我只是一个虾纸丫 提交于 2019-12-17 19:29:09
问题 How do you properly ensure that a user isnt tampering with querystring values or action url values? For example, you might have a Delete Comment action on your CommentController which takes a CommentID. The action url might look like /Comments/Delete/3 to delete the comment with the id 3. Now obviously you dont want anyone to be able to delete comment 3. Normally on the owner of the comment or an admin has permission to do so. Ive seen this security enforced different ways and would like to

C# ASP.NET QueryString parser

半腔热情 提交于 2019-12-17 18:33:39
问题 If you have been looking for a nice and clean way to parse your query string values, I have come up with this: /// <summary> /// Parses the query string and returns a valid value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key">The query string key.</param> /// <param name="value">The value.</param> protected internal T ParseQueryStringValue<T>(string key, string value) { if (!string.IsNullOrEmpty(value)) { //TODO: Map other common QueryString parameters type ... if

Is array syntax using square brackets in URL query strings valid?

早过忘川 提交于 2019-12-17 18:22:39
问题 Is it actually safe/valid to use multidimensional array synthax in the URL query string? http://example.com?abc[]=123&abc[]=456 It seems to work in every browser and I always thought it was OK to use, but accodring to a comment in this article it is not: http://www.456bereastreet.com/archive/201008/what_characters_are_allowed_unencoded_in_query_strings/#comment4 I would like to hear a second opinion. 回答1: The answer is not simple. The following is extracted from section 3.2.2 of RFC 3986 : A

ASP.NET MVC: url routing vs querystring

房东的猫 提交于 2019-12-17 17:36:13
问题 I have a page routed like /Comments/Search/3 where i search and display all the comments of the thread "3". I'm adding a sort function (by date, author etc). What is the best way to handle it? /Comments/Search/3/Sort/Author or /Comments/Search/3?sort=author ? How do I automatically handle the querystring sort=author as a parameter in MVC? Thanks 回答1: I prefer: /Comments/Search/3?sort=author. The querystring is a good place to pass in programmatic parameters, especially if the parameter (like

Query strings with special characters

好久不见. 提交于 2019-12-17 17:22:39
问题 How I can pass a query string with special characters? For example I need to pass "&" inside my query string as below: ../solrresults.asp?mode=search&data=M & S 回答1: Use Server.UrlEncode: URLEncode converts characters as follows: Spaces ( ) are converted to plus signs (+). Non-alphanumeric characters are escaped to their hexadecimal representation. Use it this way; <a href="page2.asp?name=<%= Server.URLEncode(sName) %>">here</a> 回答2: As stated, the UrlEncode method would be the way to go.

HttpServletRequest - Get query string parameters, no form data

徘徊边缘 提交于 2019-12-17 15:53:20
问题 In HttpServletRequest, getParameterMap returns a Map of all query string parameters and post data parameters. Is there a way to get a Map of ONLY query string parameters? I'm trying to avoid using getQueryString and parsing out the values. 回答1: Contrary to what cularis said there can be both in the parameter map. The best way I see is to proxy the parameterMap and for each parameter retrieval check if queryString contains "&?<parameterName>=". Note that parameterName needs to be URL encoded

301 Redirecting URLs based on GET variables in .htaccess

一世执手 提交于 2019-12-17 14:28:51
问题 I have a few messy old URLs like... http://www.example.com/bunch.of/unneeded/crap?opendocument&part=1 http://www.example.com/bunch.of/unneeded/crap?opendocument&part=2 ...that I want to redirect to the newer, cleaner form... http://www.example.com/page.php/welcome http://www.example.com/page.php/prices I understand I can redirect one page to another with a simple redirect i.e. Redirect 301 /bunch.of/unneeded/crap http://www.example.com/page.php But the source page doesn't change, only it's

elasticsearch query string dont search by word part

北慕城南 提交于 2019-12-17 13:42:52
问题 I'm sending this request curl -XGET 'host/process_test_3/14/_search' -d '{ "query" : { "query_string" : { "query" : "\"*cor interface*\"", "fields" : ["title", "obj_id"] } } }' And I'm getting correct result { "took": 12, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 3, "max_score": 5.421598, "hits": [ { "_index": "process_test_3", "_type": "14", "_id": "141_dashboard_14", "_score": 5.421598, "_source": { "obj_type": "dashboard", "obj_id":