So many new programmer are confused about post and get method for send the data. In this article i discuss about this .
The first question arise that what is the get and post method
so many developer confused he/she said that get is used for get the data from server and post is used for post the data in server this is totally wrong(in starting i am also said this ).
Both Get and Post Method are form submission method.it is used for send the data from client side to server side.
The Second Question where it is .
The method is inside the form tag like below
syntax is like below
<form method="get||post">
you use single method name get or post
Third Question is ByDefault which method is used
Ans is By default Get method are used
Now we discuss these method individually
What is the difference between these two method
Now we discuss these method individually
What is the difference between these two method
GET
|
POST
|
Data will be arranged in HTTP header by appending to the URL as query
string
|
Data will be arranged in HTTP message body.
|
Data is in query string so user can view the data
|
Data is not shown to user
|
Less secured compared to POST method because data is in query string so
it will be saved in browser history and web server logs
|
safer than GET method because data is not saved in history or web
server logs.
|
As data is saved in URL so its saves only 2048 bytes data
|
We can used any amount of data and any format
|
Can be bookmarked
|
Can’t bookmarked
|
Hacking will be easy
|
Hacking is difficult
|
Only ASCII character data type allowed
|
No restrictions. Allows binary data also
|
Caching is possible
|
No caching
|
When Use Post Method
If the form data is large then best is use POST method
because GET method cannot handle long Url.
Form data contains Non-ASCII characters use POST
because GET doesn’t support it.
Example: Usage of Get method In ASP.NET:
Example: Usage of Get method In ASP.NET:
In the below example we will see how GET method passed data from abc.html
(client) to login.aspx page (server).
abc.html
|
<html>
<body>
<form method="get"
action="login.aspx">
User Name: <input id="txtuserName" type="text" name="username" />
<input id="btnSubmit" type="submit" value="Submit data using GET" />
</form>
</body>
</html>
|
login.aspx
|
<html>
<body>
<form id="form1" runat="server">
<div>
Welcome <b><%
Response.Write(Request.QueryString["username"].ToString());
%></b>
</div>
</form>
</body>
</html>
|
Post Method:
- We can access form data in ASP.NET using Request.Form["key1"]
Example: Usage of Post method In ASP.NET:
abc.html
|
<html>
<body>
<form method="post"
action="login.aspx">
User Name: <input id="txtuserName" type="text" name="username" />
<input id="btnSubmit" type="submit" value="Submit data using POST" />
</form>
</body>
</html>
|
login.aspx
|
<html>
<body>
<form id="form1" runat="server">
<div>
Welcome <b><%
Response.Write(Request.Form["username"].ToString());
%></b>
</div>
</form>
</body>
</html>
|
Output:
Login.html
|
Now I got the real working of get and post method
ReplyDeleteNice article....very much helping
ReplyDeleteGood article
ReplyDeleteNice article. Tnx man
ReplyDeleteSorry, but I do not understand why, in both cases, you use the form method="get"?
ReplyDeletesorry i rectify it .. thanks for your error mark
ReplyDeletereally awesome i had not knowledge about it how to use get and post and what actually it is but now i am totally clear with this topic thanks rohit :)
ReplyDeletemore informative :)
ReplyDeletegud article.before that i did not know about that....
ReplyDeleteNice
ReplyDeleteNice and simple
ReplyDeletevery informative.. Thanks.
ReplyDeleteHave a look at this link http://www.etechpulse.com/2012/10/what-is-difference-between-get-and-post.html
Hi Rohit,
ReplyDeleteCould you pls confirm how did you host your own website http://www.rohitwebstudy.com/?
How much cost incurred for it?
Your guidance will help a lot!!!
Thanks,
Ashish
Very well explained. Thank u
ReplyDeleteSimple and thanks
ReplyDeletegud one.normally people guess wrong these two method
ReplyDeleteGreat Job!!!!!
ReplyDeleteI can't about ABC.HTML, how it work in asp.net
ReplyDelete