Pages

04 June 2011

1.1.3) GET POST and Query Strings

Data between a client can be sent to the server via a form or form tags in html.

The attribute method in the form tag has values GET and POST.

When the GET is used the form data is appended to the URL as a part of the query string. When the GET verb is used the data is appended to the URL as a part of the query string as a key-value pair separated by the " & "ampersand character.

ex: www.alenrk.com/pagename.aspx?Param1=value1&Param2=value2
Which is thrown to the server in the form of
GET /pagename.aspx?Param1=value1&Param2=value2
Host : www.alenrk.com

The GET method is used when you want the user to see the parameters . Do not use GET method when passing sensitive information.

For all sensitive information the POST method is used.POST removes size constraint. When the POST verb is used the data is placed into the message body of the request as follows:

POST /pagename.aspx HTTP/1.1
Host: www.alenrk.com

Param1=value1&Param2=value2

Sending data back to the server as a part of your request is reffered as a PostBack in ASP.NET.

ASP.NET Get may also be used for PostBack. Pages contain a property called IsPostBack that is used to determine if the data is a being sent back to the server or if the web page is simply being requested.

0 comments: