Get and Post vs Query String

2019-07-15 11:21发布

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

标签: asp.net
3条回答
Animai°情兽
2楼-- · 2019-07-15 11:56

You have to choose GET method especially when you want to read and choose POST when you want to write/update (database or file etc). Take a look at article - Methods GET and POST in HTML forms - what's the difference?

To learn more on ASP.NET web-app Forms.

  1. How to: Post ASP.NET Web Pages to a Different Page.
  2. ASP.NET Forms.
查看更多
smile是对你的礼貌
3楼-- · 2019-07-15 11:57
  1. If you are creating a secure website you should use POST method
  2. If you are sending a big and bulky datum to a server you have to use post because GET has some limitation.
  3. In case of URL rewriting or you are developing website where you have to use SEO in that case your URL plays an important role; in that situation you should use GET.
  4. GET is faster than POST
查看更多
一纸荒年 Trace。
4楼-- · 2019-07-15 12:14

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.

查看更多
登录 后发表回答