There are mainly two ways to pass data from one web page to another, using HTTP GET and HTTP POST method.
For example, http://PatelShailesh.com/get_targetpage.aspx?FirstName=Shailesh&LastName=Patel. In this example, string after ‘?’ is the querystring. You have to seprate querystring name value pair by ‘&’ character. So in this example there are two querystring field one is ‘FirstName’ and another is ‘LastName’ and values are ‘shailesh’ and ‘patel’ respectively.
Here’s an example of what a web server receives when a client makes a GET request:
GET /get_targetpage.aspx?firstname=shailesh&lastname=patel HTTP/1.1
User-Agent: Mozilla/4.0
Host: www.patelshailesh.com
Here is HTML example how you can pass data using HTTP GET method.
<html> <head> <title>Using Http Get</title> </head> <body> <form id=”frm_get” action=”get_targetPage.aspx” target=”_blank” method=”GET” > <table> <tr> <td>First Name: </td> <td><input type=”text” id=”txtFirstName” name=”firstname” /></td> </tr> <tr> <td>Last Name: </td> <td><input type=”text” id=”txtLastName” name=”lastname” /></td> </tr> <tr> <td></td> <td><input type=”submit” value=”Send Using Get” /></td> </tr> </table> </form> </body> </html>
When you click on submit button, Page will be redirected get_targetPage.aspx(as stated in action attribute of form element). You will see url like this http://yourcurrentwebsite/get_targetPage.aspx?firstname=valueyouhaveentered&lastname=valueyouhaveentered. Querystring field like ‘firstname’ and ‘lastname’ are taken from name attribute of input text element. So DONOT forget to specify name attribute.
If you want to pass value of variable or only some portion of data to another page, you can use response.redirect. For example, on button click event you can write code like this.
protected void btnSubmit_OnClick(object sender, EventArgs e)
{
string firstNameValue = 'Shailesh';
string URL = "firstName=" + firstNameValue ;
//added firstname variable value in querystring
URL += "&lastName=" + txtLastName.Text ;
// added valued entered in txtlastname textbox in querystring
Response.Write("get_targetPage.aspx?" + URL);
// url will be http://yourcurrentwebsite/get_targetPage.aspx?firstname=Shailesh&lastname=valueyouhaveenteredintxtlastnametextbox
}
Following code to retrieve the data from querystring in target page
string firstName = Request.QueryString["firstname"].ToString(); // will get 'shailesh' string lastName = Request.Querystring["lastname"].ToString(); // will get 'patel'
2) HTTP POST: In HTTP POST request data are embeded in a HTTP HEADER. So data are NOT visible to end user while you can see the data passed in HTTP GET method. So if you want to pass sensitive information/data, you should have to use HTTP POST request. Another advantage is that you can send larger amounts of information compare to HTTP GET method.
Here’s an example of what a web server receives when a client makes a POST request:
POST /post_targetpage.aspx HTTP/1.1
Host: www.patelshailesh.com
User-Agent: Mozilla/4.0
Content-Length: 27
Content-Type: application/x-www-form-urlencoded
firstname=shailesh&lastname=patel
Here is HTML example how you can pass data using HTTP POST method.
<html> <head> <title>Using Http Post</title> </head> <body> <form id=”frm_post” action=”post_targetPage.aspx” target=”_blank” method=”POST” > <table> <tr> <td>Name 2: </td> <input type=”text” id=”txtFirstName" name="firstName" /> </td> </tr> <tr> <td>Address 2: </td> <input type=”text” id=”txtLastName" name=”lastName" /> </td> </tr> <tr> <td></td> <td><input type=”submit” value=”Send Using Post” /> </td> </tr> </table> </form> </body> </html>
When you click on submit button, Page will be redirected post_targetPage.aspx(as stated in action attribute of form element). You will see url like this http://yourcurrentwebsite/post_targetPage.aspx. Please not here you won’t see any querystring appended in URL since we are making HTTP POST request. Note: You might have noticed that above example is purely HTML code. In ASP.NET by default all the pages post to themselves. In if you want to make HTTP POST request, you are thinking to change METHOD and ACTION attribute. But you can’t do that unless you remove ‘runat=server’ attribute which will disable the other features provided in ASP.NET. So you are thinking how you can make HTTP POST request. ASP.NET 2.0 or later version, there is a PostBackUrl property of the ASP.NET control that can submit the page. PostBackURL property specifies which page to submit data making HTTP POST request. Here is the syntax <asp:Button ID=”btnSubmit” Runat=server Text=”submit” PostBackUrl=”~/Post_TargetPage.aspx” /> Following code to retrieve the data in target page
string firstName = Request.Form["firstname"].ToString(); // will get 'shailesh' string lastName = Request.Form["lastname"].ToString(); // will get 'patel'
Hope this article clears out your doubt between HTTP GET and HTTP POST request. If this post really helps you, please click the Google +1 button to show it really helps you save your time. Please leave a comment/question here.

Thanks for the article.Its good and clears the doubts in the get and post method.
Thanks the author for article. The main thing do not forget about users, and continue in the same spirit.
The subject is fully clear your blog is great.
This article is good
Especially the narration was good understandable manner
thanks shailesh
keep post this type of articles
This was an excellent article, you would think there would be more full examples of HTTP POST specifically. Thankfully, I found this one.
Keep it up.
Going to pay attention to your outstanding article, I study it is definitely of the special statements and leading thoughts.Trust that I will certainly get maintain of just what I aspire arriving through your present thoughts.Best wishes with you!
Super!!!
Excellent !!!!
This is really good article.
Helps a lot. Thanks you.
Really good article, cleared all my doubts.
how do you POST the data from an ASPX?
I understand the form from HTML, php or classic ASP,
But in ASP.NET, you already have a FORM runat=server, So you can’t add forms in it.
How would I do it from the ASPX?
@Krush
When you look at the .aspx page, you won’t see action and method attributes of form element. By default form uses HTTP Post method and value of “action” attribute is that page itself. If you look at the view source of any .aspx page in browser, you will see those values generated by ASP.NET.
ASP.NET uses HTTP Post by default for .aspx and form is posted to itself by default.
Wonderful article shailesh
if you are using postbock URL in the submit button, the value will not visible in the Header.
I hope here post method will not give any impact.
ipage web hosting guide
How can i use http post and get method on .aspx page? Please let me know with the example.
it is a gud article.
hey you
you saved my time a lot
thanks
i migrated from asp classic to asp.net and was so confused about get a post method,
thanks a million
Thankx Buddy,
Thank you somuch