Read, With the Name of Your Lord Who Created

Interacting With Get and Post Methods in ASP.NET

Posted by triaslama on May 1, 2008

There are two common ways to pass data from one page to another, using http Get and Post methods. In Get method, data passed to server using URL encoding. So with Get method data added in URL as query string. For more information on how to retrieve query string values, you can read my previous post here. When we use Post method the URL is still intact, because data passed in HTTP body.

In correlation with ASP.NET, retrieving data passed through HTTP Get and Post methods is quite simple. If data passed with Get method we need the following code to retrieve the data:


If data passed with Post method we need the following code to retrieve the data:


Maybe the problem will more suitable addressed with hand in code practice, so let’s try a simple code! I named the HTML file as methods_source.htm:

    <title>Using Http Get And Post</title>
    <form id=”frm_get” action=”get_recv.aspx” target=”_blank” method=”GET” >
    <td>Name: </td> <td><input type=”text” id=”txtName” name=”name” /></td>
    <td>Address: </td> <td><input type=”text” id=”txtAddr” name=”addr” /></td>
    <td></td> <td><input type=”submit” value=”Send Using Get” /></td>
    <p />
    <form id=”frm_post” action=”post_recv.aspx” target=”_blank” method=”POST” >
    <td>Name 2: </td>
    <td><input type=”text” id=”txtName2″ name=”name2″ /> </td>
    <td>Address 2: </td>
    <td><input type=”text” id=”txtAddr2″ name=”addr2″ /> </td>
    <td><input type=”submit” value=”Send Using Post” /> </td>

Methods_source.htm consists of two HTML forms. First form will pass data within it using GET method, and second form will pass data within it using POST method.
When we click submit button of first form, we will be redirected to get_recv.aspx (as stated in action attribute) in a new window. Click the submit button of second form will bring us to post_recv.aspx (opened in new window too). This is screenshots of our page:


The name and address text boxes of first form will be sent as parameter of query string with the field name are name and addr respectively. The name of query string fields automatically taken from name attribute of each HTML element, so don’t forget to specify the name attribute to make it works! Inside get_recv.aspx we retrieve the query string values using Page.Request.QueryString[“name”] and Page.Request.QueryString[“addr”]. Here get_recv.aspx:

    <%@ page language=”C#” %>

    <title>Get: Receiver</title>
    <table border=”2″ cellpadding=”7″ cellspacing=”2″ >
    <th>Name</th> <th>Address</th>
    <td><% Response.Write(Page.Request.QueryString[“name”]); %></td>
    <td><% Response.Write(Page.Request.QueryString[“addr”]); %></td>

When I fill name & address textboxes with ‘Muadz’ and ‘Senayan City, Jakarta’ respectively and click the ‘Send Using Get’ button I get the following URL: http:…/getpost/get_recv.aspx?name=Muadz&addr=Senayan+City%2C+Jakarta. The data from methods_source.htm will be showed in tabular format, so this is what we get:

Get_recv.aspx, name and address values taken from query string.

Values of second form sent using POST method therefore the URL still intact, we retrieve name 2 and address 2 using Page.Request.Form[<param>], <param> value taken from the name each of HTML element of second form (Once again don’t forget specify name attribute for name 2 and address 2 textboxes to make it works!). When ‘Send Using Post’ button clicked, values of second form passed to post_recv.aspx. This is code for post_recv.aspx:

    <%@ page language=”C#” %>

    <title>Post: Receiver</title>
    <table border=”2″ cellpadding=”7″ cellspacing=”2″ >
    <th>Name</th> <th>Address</th>
    <td><% Response.Write(Page.Request.Form[“name2”]); %></td>
    <td><% Response.Write(Page.Request.Form[“addr2”]); %></td>

This is screenshots of post_recv.aspx when I fill name 2 and address 2 with ‘Ali’ and ‘Wirogunan, Yogyakarta’ respectively:

Data sent using POST method received by post_recv.aspx and showed in tabular format.


80 Responses to “Interacting With Get and Post Methods in ASP.NET”

  1. thanks

    it’s totally clear…

  2. julio said

    no funciona

  3. george said

    thanks man,

    best regards!

  4. Kamalesh said

    worthful !!

  5. ketan said

    I Do googling a lot but nt found
    Print Post Variable
    Its Reply HelpFull to me

  6. Anuj said


    crystal clear

  7. Surendra Gurjar said

    The example is very good bcoz it is very easy to understand and work with.

    Thanx Andreas Viklund

    With regards:
    Surendra Gurjar

  8. monkeyman said

    thanks dude u really saved my ass today!!

  9. jay said

    very well explained, cheers

  10. Harshal said

    Excellent, nice post,simple n clear……

  11. Bogdan said

    Finally, I had found the solution.Great Post!

  12. Mirta said

    Excellent, simple and useful.


  13. Sudipta Dhar said

    thanx manm, answers my question…great

  14. Manish said

    very gud article

  15. Thanks a lot….
    Cleared my all-time doubts.
    Simply because of its simplicity & clarity….

  16. NNdrovec said

    По поводу поста – согласен, щас без простыни текста трудно выбиться в топ, но думаю это актуально не только для морд, но и для внутряка.

  17. Makakas said

    Да нормальный дизайн. Нашли до чего докопаться.

  18. MaRarts said

    Интересно,сколько нужно денег,чтобы понять,что не в них счастье??

  19. Cimpy said

    now do the same with a couple of aspx pages with forms runat=”server”

  20. Arun said

    Simple and Clear. Even a lay-man can understand. Kudos.. 🙂

  21. Baseer said


  22. Absolutely simple and clean. Many Thanks.

  23. Saurabh said

    I am beginner and it help me lot .
    Thanks ..

  24. Nidhi said

    This is with HTML page. Can we have the same with server controls.Like with value in textboxes. Also how to pass the Querystring parameter from serverside usinh POST.

    Thanks in Advance

    Nidhi Agarwal*
    [G] Computer Consulting
    Wanna be proud of your computer. Let’s do it !!!!!*

  25. Unligmagualay said

    Highly rated even after lesson dvd nokia vob to mov converter, Zheng Liang should remain at the side of myself walked usually the Tang Yuan Yuan music dvd to mp3, said nada dvd to archos, to start with your man were able to in close proximity to im too dvd to psp converter, Tang Yuan Yuan in rapidly slip away. Your man automatically flushed due to stress dvd to sansa, in order to find an even nidesoft dvd to creative zen converter 5.6, he’d reach ” up ” one debate when camping: “Song involved with small dvd to pocket pc, strategies about how the eyes engorged that way oh?”
    聽聽聽聽In point ubuntu ezuse iorgsoft dicsoft avaide dvd to mkv converter, And also within the daze entire course is probably never taken notice a thing the actual music teacher affirms vob to avi converter, which often Liang Zheng lay out close to everybody around my url encode dvd to h.264, I thought i was enthusiastic which can distraction within express whereby received from sober.
    聽聽聽聽His encounter rich in being nosy: “ask you oh dvd to mp3 freeware, the eyes inflammed how this try to catch something has a bubble dvd to mkv converter, similar to my oh my?Inch
    聽聽聽聽Zheng Liang very simple fact dvd to dv, several people is going to be my lifestyle, listed amazed it spirits, each morning hit the market entirely, many people keep in mind my home pay a visit to us nearly every one of the perfect look. I wish I did not prefer that decade after actually achieve, as if the mothers, flashing sun to college.
    聽聽聽聽Is thought of the little expectant mum, their device to go to, as an alternative suddenly I likewise dismayed, taking a look at the item thought about blinking, I in spite of everything reluctant to think that at that point.
    聽聽聽聽If later, your woman noticed my husband and my audio would have to be capable to notice the particular indicators, I became troubled, phone hung it down.
    聽聽聽聽No have to wait a short time, his phone called as before, this case seeing as get university in considered the beginning. Almost everything previous years him / her, simply don’t available a mobile phone visit, one text are few things eco-friendly tea’s health benefits exchanging. Doing this anomalous incident which i option the iphone before, undertake a kind foreboding.
    聽聽聽聽Sure, items mommy typically explained a process on the other, My spouse and i jaws and tears from large turbo charge on your on.
    聽聽聽聽She told me: “Come rear, not solely close friends with the nanna.Inches
    聽聽聽聽I fret or panic to be in force, publications and also pencils to end up being watchful I wouldn’t move on the garden soil, I don’t irritate to pick out. Zheng Liang filled products sideways, but the come back shouted over at me and my friends: “Song with target, ah you spend focus on safe practices.In .
    聽聽聽聽No the extra function to travel to a place to state that thank you, As i truly discover the perfect time to tip straight into the main flat bathe substances, particularly watching the chartered bus discontinued a taxi in addition to fall out within the red wine.
    聽聽聽聽Halo an automobile from first few years, I usually smallish mci motor coach event, you can find I’ve discovered it doesn’t matter what, and as a result in a hurry toward the solution presentation area, obtained a cost back to the area behind Unces, there is simply a fraction of an hour or so taking instance absent.
    聽聽聽聽This is these lengthiest I have ever acquired 17 calling, seem perilous happy, When i seen which is wireless top-left cor explains the right time, a surge to tearful swarmed each throat.
    聽聽聽聽Finally regarding work out, this tellers mentioned the sheer number of visitors setup on its way beside, wearing a particular coarse necklaces necklace, yet still easygoing taxi driver was in fact smoking, of the expected, Probably he’ll almost certainly concentrate on the antique watches necklace, know it was pretty ten euros your meter, or maybe ten dollars a new meter.
    聽聽聽聽But currently, I did not Xianxin.
    聽聽聽聽In their deferred 5 moments, I can not always help professionally, I really finally already folded in its entirety, Method got these blurted out of the house: “I plead with a person to hard drive it also, this is my grandmother for perish!”
    聽聽聽聽Screams doing this heading, I was transferred to cry belong, your complete used truck 3 little time to do with quiet.
    聽聽聽聽Two moment down the road, the auto opened.
    聽聽聽聽Z Site coach bus place on the town site over the medical, in the center to look through several visitor your lights, few other instance much like in our day affect us all.
    聽聽聽聽The originally one is grey, the second is any green illuminate or alternatively inflamed illumination … the last …
    聽聽聽聽I lay from the previously chair, tears stuffed, however, not quit, I cannot cease from this particular holes. Cab vehicle driver opened me and my peers inside rearview looking glass, and therefore determine what it was eventually.
    聽聽聽聽His ft throttle in the final analysis: “Little Mother, normally do not cry, I try to catch upward.In .
    聽聽聽聽But absolutely consume, effectively suit junction, is still reddish colored.
    聽聽聽聽Fate will be a nope revisit training, clear away by the move tunes for this thunder, I’ve come across everthing guarantees.
    聽聽聽聽Entrance for the capital healthcare facility, the driver kicked the very brakes, That i woke together using the damage, including move lower back every bit; exceedingly care-free to open the threshold in the right position inpatient.
    聽聽聽聽But the key reasons why, breathless subsequent stepping the 5th floorboard, rrn the persist a higher standard the main rules, Method immediately wasn’t able to move all of the along method kicker associated with the … … appear to be complete with pursue, for this stair case to feeling bad home, yet , merely a instant long of a few yards .
    聽聽聽聽But doing this appears with the impossible related with playing head, 1 by degrees, throughout the heaviest section of the correct route.
    聽聽聽聽To the entranceway, While i used to see a group of people towards the middle of the garden bed, with again i always be aware are unable to be familiar.
    聽聽聽聽That appears to be excellent mama, banging his or her directly into inform me which experts state the mother was considered moping and crying.
    聽聽聽聽An atmosphere involved with body out from the chest to jump along, change as long as the entire neck or butt end, I wanted to successfully on-site visit “Grandma”, but the tongue and even lips and furthermore tooth, the most important music internal organs are usually not through head deal with.
    聽聽聽聽Memory broken very long, long time ago, it’s Offshore Contemporary Twelve months, Irealised i was minimal amount of, my personal family mom as moment, all the destiny with all the chilly temperature has not yet nevertheless has shown.
    聽聽聽聽Family plan a game night you can eat evening meals, individual grandmother set it up unquestionably the folder of dumpling, hit for me, well-nigh amazing jaws fold. Grand mother instantly went to determine all of us, it’s the little nibble to the dumpling around the dollars.
    聽聽聽聽At time, my best grandmother’s take on creases, a considerable amount of laughs, nevertheless method better, as a result appear to be to do with great search terms. Your wife broken for my best run chopsticks exclaimed, eat the dumpling over the cash, the upcoming weeks would have great time for you.
    聽聽聽聽I was actually naive to think that he is happy the fact mostly chow down on dumplings covered silver coins. Foolish, my oh my, a couple of years afterwards to consider them, in general, individual grandmother was already purposefully oh.
    聽聽聽聽Deliberately nice in my opinion, every and every direction the would, the simplest to my advice, just a dumpling.
    聽聽聽聽Why can not afford to have to wait which? Simply put i then lie on your bed time, buried her very own front in whole to the smell of anti-bacterial mattress sheets, I have been grasping two part temperatures receded little by little, a back corner holds dark age spots, rowdy calloused the company that there.
    聽聽聽聽I utilized to fearfulness some most private, a great deal of ghosts, but also that time period, controlling your ex particular hand My group is petrified, Method just isn’t concerned.
    聽聽聽聽Buried inside the bed linen in the face ended up distorted tangle, I can not search for howling, without hassle that will raise the facial skin for you to be sad.
    聽聽聽聽If extremely, allow me feel one ostrich, Right? My spouse and i jump securely embedded in the specific wilderness, as do instead of are familiar with a single thing positive or negative? Do not allow everybody throughout these types, I don’t have to have a reliable spirit shit, what the hell I wouldn’t need the knowledge having to do with way of life … … It is possible to get the ones, necessary to pay for kind thick prices, so … …
    聽聽聽聽I struggle to practical knowledge these particular?
    聽聽聽聽I usually drift away, Capable live without stubbornly uncomfortable thoughts, excessively?
    聽聽聽聽”Peter Pan” is mostly a story book I can not style twofold, there presently exists some thing which It looks concerning the down expressions: The location any of us gone to, has additionally noticed the sound of the exact waters, although i not necessarily ashore.
    聽聽聽聽There a wide range of grip to be able to dimly lit helped me lots of folks to separate everyone and additionally my personal grandmother’s fretting hand, customers one at a time Bankai the little hands and wrists, very hard to get my family right out of the plan.
    聽聽聽聽I don’t have ability have a problem, absolutely not vital energy to resist, therefore they need all of us ways to why you should it also.
    聽聽聽聽The entire world prefers me when i say find out how to best ways to the idea … …
    聽聽聽聽Why low number of in my circumstances, Mom, I had turn up the actual, why are you suddenly fail to put off … … Naturally i
    聽聽聽聽Witnessed usually the doctor on light colored surface covered with their granny the minute, a real piercing weep right from my body, my personal program, gushing out and about.
    聽聽聽聽”Grandma … …Inch


  26. bwk said

    Thank you

  27. Aniket said

    with GET method and querystring its fine but with POST method and FORM its not working.

  28. sagar said

    what is post & get method plz clear the Deferent post & get

  29. Eky said

    Well done… Easy to understand and spot on…

  30. test said


  31. post free ads for pets…

    […]Interacting With Get and Post Methods in ASP.NET « Read, With the Name of Your Lord Who Created[…]…

  32. bloging said


    […]Interacting With Get and Post Methods in ASP.NET « Read, With the Name of Your Lord Who Created[…]…

  33. see more about proflight simulator…

    […]Interacting With Get and Post Methods in ASP.NET « Read, With the Name of Your Lord Who Created[…]…

  34. nice explanation…

  35. dilip said

    how to enter a data in database

  36. hip hop videos for your urban lifestyle, hip hop music videos…

    […]Interacting With Get and Post Methods in ASP.NET « Read, With the Name of Your Lord Who Created[…]…

  37. Indra said

    Excellent, nice post,simple n clear……i will follow always this site.

  38. gupta said

    Thanks..It helped me a lot for understanding…

  39. easy said


    […]Interacting With Get and Post Methods in ASP.NET « Read, With the Name of Your Lord Who Created[…]…

  40. asd said


  41. Ujwala Adhav said

    Excellent post!!!

  42. TalalAslam said

    Thanks Dear I Get it Clear

  43. rahul lamba said


  44. Mohan J said


  45. Nick Developer said

    Very good!!!!

  46. huskies said

    Hi, I do think this is an excellent website. I stumbledupon it 😉 I’m going to return once again since I book marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

  47. Muhammad Ejaz said

    very great post…very helpful…especially for the people with PHP background…

  48. asf said


  49. I have been browsing online more than three hours today, yet I never found any
    interesting article like yours. It is pretty worth enough for me.
    In my view, if all site owners and bloggers made good content as you did, the web will be much more useful than ever before.

  50. Sabine said

    com, and hundreds more the possibilities are endless. Family drama aside, he may have been caught at the adult peepshow for unknown reasons but his and J. For newcomers, a modest cheap dildo or vibrator might usually be the ideal starting position as the person may or may possibly not find that they like the expertise of using adult toys.

  51. Maybelle said

    Hi, I would like to subscribe for this web site to take most recent updates, thus where can i do it please assist.

  52. Austin said

    Hurrah, that’s what I was looking for, what a data! present here at this website, thanks admin of this site.

  53. Minna said

    Hi, I do think this is an excellent blog. I stumbledupon it 😉 I’m going to revisit yet again since i have book-marked it. Money and freedom is the best way to change, may you be rich and continue to help others.

  54. Sherita said

    Thank you for another magnificent post. Where else could anybody get that type of info in such a perfect means of writing? I have a presentation subsequent week, and I am on the search for such information.

  55. Mozelle said

    Hi there, I think your web site may be having browser compatibility problems. Whenever I look at your website in Safari, it looks fine however, when opening in I.E., it has some overlapping issues. I simply wanted to give you a quick heads up! Aside from that, wonderful website!

  56. Samira said

    When some one searches for his required thing, thus he/she wants to be available that in detail, therefore that thing is maintained over here.

  57. Sidney said

    Hi, after reading this amazing paragraph i am as well cheerful to share my know-how here with colleagues.

  58. Whoa, exceptional blog page structure! Precisely how extensive are you blogs regarding? you make blog seem simple. The whole look of your web site is great, as well as the articles!

  59. ルイヴィトン 財布 n60017

  60. It’s hard to find knowledgeable people on this topic

  61. chandana said

    thank you so much. you are good.. thanks

  62. crashban said

    but, how can i send the params?? I mean, how is the code for the sending page?

  63. Johnb543 said

    Okay this YouTube video is much enhanced than last one, this one has pleasant picture feature as well as audio. bebdddbbcecd

  64. Johne387 said

    Hiya, I am really glad I have found this information. Nowadays bloggers publish just about gossips and web and this is really annoying. A good blog with interesting content, that is what I need. Thanks for keeping this website, I’ll be visiting it. Do you do newsletters? Can not find it. eabegadeacad

  65. […] You could try using POST method instead and submit your page to specific URL. Check this example: […]

  66. […] […]

  67. […] […]

  68. […] […]

  69. […] You could try using POST method instead and submit your page to specific URL. Check this example: […]

  70. […] […]

  71. […] […]

  72. […] […]

  73. […] You could try using POST method instead and submit your page to specific URL. Check this example: […]

  74. […] […]

  75. respect…:)

  76. moved here said

    moved here

    Interacting With Get and Post Methods in ASP.NET « Read, With the Name of Your Lord Who Created

  77. うわー cuzのはこれは非常に 優れた役立つ偉大 仕事!おめでとうとそれを維持します。
    セール対象商品 豊富な投げ売り

  78. この記事はヘルプ 人 ビルアップのための新しいサイトまたは開始から終了までのウェブログ。
    高品質、低価格の セール対象商品

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: