Powered by Blogger.

Thursday, March 13, 2014

Query String in Asp.Net



In this post we will discuss about Query String in Asp.Net. Also you can check out:

- Export gridview data to excel sheet in Asp.net

- Working with enterprise library for data access in asp.net Part-3

- Bind dropdownlist from enum in Asp.Net

Like view state and cross page posting, query string is also a state management technique. This helps us to send data from one page to other page.

Here the data will be send through the browser URL.

Example:
Below is a way to send the data to a different page.

Response.Redirect("ArticleDetails.aspx?ArticleID=1");

Similarly below is a ways, we can retrieve the query string data:
string articleID = Request.QueryString["ArticleID"];

We can also send multiple parameters by using query string like below:

Response.Redirect("ArticleDetails.aspx?ArticleID=10&Category=Asp.Net");

Query string is very much lightweight, so there will be very less burden on the server. But there are few limitations in this also:

Limitations of Query String:
- Information is limited to simple strings, which must contain URL-legal characters, since its passed through browser url.

- Information is clearly visible to the user and to anyone can trap the values.

- The user also can modify the value and can send the new values to the server.

- Most of the browser has limitation on the length of the url (1 KB to 2KB), so we can not send large amount of data.





0 comments

Post a Comment