Difference Between GET and POST

Get and Post both are used for sending client information to web server means both methods are used to transfer data from client to server.
 
Security : In the case of security post is more secure. because for this we have some differences.
 
Get

Data is passed from client in the form of Url and Url data is visible to every user if you are submitting any form then data which you are passing will be visible in Url ,so this will not safe. also we have some restrictions on that you can pass only 1024 characters in the case of Get.
 
Example for this
 
I have a application from where i will pass data
 
GetMethod.aspx  
  1. <html  
  2.     xmlns="http://www.w3.org/1999/xhtml">  
  3.     <body>  
  4.         <form method="get" action="GetDataUsingget.aspx">  
  5. User Name:   
  6.             <input id="txtuserName" type="text" name="username" />  
  7.             <input id="btnSubmit" type="submit" value="Submit data using GET" />  
  8.         </form>  
  9.     </body>  
  10. </html>  
 
 
From there i have entered my name and then data will be posted on  "GetDataUsingget.aspx" page.
 
After clicking on button this will be like as shown in below picture
 
 
 
 
For performing this operation i have used this code: 
  1. <html  
  2.     xmlns="http://www.w3.org/1999/xhtml">  
  3. </head>  
  4. <body>  
  5.     <form id="form1" runat="server">  
  6.         <div>  
  7. Welcome   
  8.             <b><% Response.Write(Request.QueryString["username"].ToString()); %>  
  9.             </b>  
  10.         </div>  
  11.     </form>  
  12. </body>undefined</html>  
Post

On the case of post Method data will be passed through http headers  so using secure http protocol and data will be more secure and also we have no data restriction there we can pass large number of data and binary data we can pass here also.
 
Prcactical example for this- 
  1. <html  
  2.     xmlns="http://www.w3.org/1999/xhtml">  
  3. </head>  
  4. <body>  
  5.     <form method="post" action="PostMethod.aspx">  
  6.       User Name:   
  7.         <input id="txtuserName" type="text" name="username" />  
  8.         <input id="btnSubmit" type="submit" value="Submit data using GET" />  
  9.     </form>  
  10. </body>undefined</html>  
If you will click on submit button the.
 
PostMethod.aspx 
  1. <html xmlns="http://www.w3.org/1999/xhtml">  
  2.    </head>  
  3.    <body>  
  4.        <form id="form1" runat="server">  
  5.            <div>  
  6.                   Welcome   
  7.                <b><% Response.Write(Request.Form["username"].ToString()); %>  
  8.                </b>  
  9.            </div>  
  10.        </form>  
  11.    </body>
  12.    undefined
  13. </html>  
Ebook Download
View all
Learn
View all