Helper Helper - 1 month ago 4
ASP.NET (C#) Question

Get and Post vs Query String

Whenever we redirect from one page to another page, Query string can be used. Now when i used the "GET" and "POST" methods in the form tag.

I have got the following findings.


  1. Get - Exposes is the data of password fields in the URL. SO it should not be used. Right?

  2. POST - Some unnecessary data can be accessed from Request .Form of the textbox fields which is not required.



I think, while navigating to another page, I can use Query String on clikcing the button like below.

Response.Redirect("abc.aspx?id=10") //This will be at the code behind level.


and similarly we can use in Java Script like below.

function RedirecToAnotherPage(){
window.open('abc.aspx?id=10');}


Right?

Here, my query is in which case, I can use the "GET" and "Post" method in real life/dynamic website

Answer

POST removes constraints that GET has, like maximum query string size. You can control what data is sent by controlling which fields are inside the form tag. You can have multiple form tags and post the relevant one.