I have a code example like this :
location.href = location.href + "/Edit?pID=" + hTable.getObj().ID; ; //aspx parID = Request.QueryString["pID"]; //c#
it works, my question is - how ? what is the logic ? thanks :)
To pass in parameter values, simply append them to the query string at the end of the base URL. In the above example, the view parameter script name is viewParameter1.
The QueryString collection is used to retrieve the variable values in the HTTP query string. The line above generates a variable named txt with the value "this is a query string test". Query strings are also generated by form submission, or by a user typing a query into the address bar of the browser.
A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML, choosing the appearance of a page, or jumping to positions in multimedia content.
Yes, your query strings will be encrypted. The reason behind is that query strings are part of the HTTP protocol which is an application layer protocol, while the security (SSL/TLS) part comes from the transport layer.
The HttpRequest
class represents the request made to the server and has various properties associated with it, such as QueryString
.
The ASP.NET run-time parses a request to the server and populates this information for you.
Read HttpRequest Properties for a list of all the potential properties that get populated on you behalf by ASP.NET.
Note: not all properties will be populated, for instance if your request has no query string, then the QueryString
will be null/empty. So you should check to see if what you expect to be in the query string is actually there before using it like this:
if (!String.IsNullOrEmpty(Request.QueryString["pID"])) { // Query string value is there so now use it int thePID = Convert.ToInt32(Request.QueryString["pID"]); }
A query string is an array of parameters sent to a web page.
This url: http://page.asp?x=1&y=hello Request.QueryString[0] is the same as Request.QueryString["x"] and holds a string value "1" Request.QueryString[1] is the same as Request.QueryString["y"] and holds a string value "hello"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With