Questions tagged [query-string]

The part of a URL after the ? (question mark), containing parameter=value pairs separated by & (ampersand). In a request made to a web application at a particular URL, the parameter+value data in the query string is parsed/consumed by the web application on the backend that receives the request.

See also: https://en.wikipedia.org/wiki/Query_string

5108 questions
428
votes
9 answers

Is a HTTPS query string secure?

I am creating a secure web based API that uses HTTPS; however, if I allow the users to configure it (include sending password) using a query string will this also be secure or should I force it to be done via a POST?
John
  • 29,788
  • 18
  • 89
  • 130
415
votes
11 answers

Parse query string in JavaScript

I need to parse the query string www.mysite.com/default.aspx?dest=aboutus.aspx. How do I get the dest variable in JavaScript?
sinaw
  • 4,195
  • 2
  • 16
  • 5
374
votes
11 answers

Get URL query string parameters

What is the "less code needed" way to get parameters from a URL query string which is formatted like the following? www.mysite.com/category/subcategory?myqueryhash Output should be: myqueryhash I am aware of this…
enloz
  • 5,704
  • 9
  • 37
  • 56
320
votes
5 answers

Get querystring from URL using jQuery

I have the following URL: http://www.mysite.co.uk/?location=mylocation1 I need to get the value of location from the URL into a variable and then use it in jQuery code: var thequerystring =…
Tom
  • 12,776
  • 48
  • 145
  • 240
304
votes
19 answers

Get escaped URL parameter

I'm looking for a jQuery plugin that can get URL parameters, and support this search string without outputting the JavaScript error: "malformed URI sequence". If there isn't a jQuery plugin that supports this, I need to know how to modify it to…
Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
278
votes
8 answers

Escaping ampersand in URL

I am trying to send a GET message that contains strings with ampersands and can't figure how to escape the ampersand in the URL. Example: http://www.example.com?candy_name=M&M result => candy_name = M I also…
tomermes
  • 22,950
  • 16
  • 43
  • 67
271
votes
14 answers

How to read values from the querystring with ASP.NET Core?

I'm building one RESTful API using ASP.NET Core MVC and I want to use querystring parameters to specify filtering and paging on a resource that returns a collection. In that case, I need to read the values passed in the querystring to filter and…
user1620696
  • 10,825
  • 13
  • 60
  • 81
271
votes
4 answers

REST API Best practices: args in query string vs in request body

A REST API can have arguments in several places: In the request body - As part of a json body, or other MIME type In the query string - e.g. /api/resource?p1=v1&p2=v2 As part of the URL-path - e.g. /api/resource/v1/v2 What are the best practices…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
254
votes
13 answers

Angular: How to update queryParams without changing route

I am trying to update (add, remove) queryParams from a component. In angularJS, it used to be possible thanks to : $location.search('f', 'filters[]'); // setter $location.search()['filters[]']; // getter I have an app with a list that the user…
Olivier
  • 3,121
  • 2
  • 20
  • 28
245
votes
16 answers

How to remove the querystring and get only the URL?

I'm using PHP to build the URL of the current page. Sometimes, URLs in the form of www.example.com/myurl.html?unwantedthngs are requested. I want to remove the ? and everything that follows it (querystring), such that the resulting URL…
Navi Gamage
  • 2,663
  • 2
  • 19
  • 18
242
votes
16 answers

How can I get (query string) parameters from the URL in Next.js?

When I click on a link in my /index.js, it brings me to /about.js page. However, when I'm passing parameter name through URL (like /about?name=leangchhean) from /index.js to /about.js, I don't know how to get it in the /about.js…
Sour LeangChhean
  • 7,089
  • 6
  • 37
  • 39
240
votes
5 answers

Optional query string parameters in ASP.NET Web API

I need to implement the following WebAPI method: /api/books?author=XXX&title=XXX&isbn=XXX&somethingelse=XXX&date=XXX All of the query string parameters can be null. That is, the caller can specify from 0 to all of the 5 parameters. In MVC4 beta I…
frapontillo
  • 10,499
  • 11
  • 43
  • 54
240
votes
32 answers

Change URL parameters and specify defaults using JavaScript

I have this URL: site.fwx?position=1&archiveid=5000&columns=5&rows=20&sorting=ModifiedTimeAsc what I need is to be able to change the 'rows' url param value to something i specify, lets say 10. And if the 'rows' doesn't exist, I need to add it to…
Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
236
votes
5 answers

Add querystring parameters to link_to

I'm having difficultly adding querystring parameters to link_to UrlHelper. I have an Index view, for example, that has UI elements for sorting, filtering, and pagination (via will_paginate). The will_paginate plugin manages the intra-page…
craig
  • 25,664
  • 27
  • 119
  • 205
236
votes
6 answers

Does a `+` in a URL scheme/host/path represent a space?

I am aware that a + in the query string of a URL represents a space. Is this also the case outside of the query string region? That is to say, does the following URL: http://a.com/a+b/c actually represent: http://a.com/a b/c (and thus need to be…