query string in asp.net

A query string is information that is appended to the end of a page URL. 

We can use a query string to submit data back to our page or to another page through the URL.

Query strings provide a simple but limited way of maintaining some state information.

For example :

 Query strings are an easy way to pass information from one page to another, such as passing a product number to another page where it will be processed. 

A typical query string might look like the following real-world example:

http://support.microsoft.com/Default.aspx?kbid=315233 

In this example, the URL identifies the Default.aspx page. The query string (which starts with a question mark [?]) contains a single parameter named “kbid,” and a value for that parameter, “315233.” Query strings can also have multiple parameters, such as the following real-world URL, which specifies a language and query when searching the Microsoft.com Web site:

http://search.microsoft.com/results.aspx?kbid=315233&setlang=en-US

 Advantages of using query string in asp.net :

No server resources are required:  

The query string is contained in the HTTP request for a specific URL.

Widespread support:   Almost all browsers and client devices support using query strings to pass values.

Simple implementation:  

ASP.NET provides full support for the query-string method, including methods of reading query strings using the Params property of the HttpRequest object.

Disadvantages of using query string in asp.net :

Potential security risks:   The information in the query string is directly visible to the user via the browser’s user interface. A user can bookmark the URL or send the URL to other users, thereby passing the information in the query string along with it.

If you are concerned about any sensitive data in the query string, consider using hidden fields in a form that uses POST instead of using query strings.

 Limited capacity:   Some browsers and client devices impose a 2048-character limit on the length of URLs. 

query string example

source view

code view

Accessing QueryString Values on another Page: AccessQueryStringExample.aspx

code view