Difference between Request.Form and Request.QueryString?

前端 未结 6 537
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 17:02

Can some tell me the exact difference between Request.Form and Request.QueryString?

I know one difference, like

If th

6条回答
  •  青春惊慌失措
    2021-02-02 17:13

    As stated on MSDN,

    (Request.Form): The value of Request.Form(element) is an array of all the values of element that occur in the request body. You can determine the number of values of a parameter by calling Request.Form(element).Count. If a parameter does not have multiple values associated with it, the count is 1. If the parameter is not found, the count is 0.

    and (Request.QueryString): The value of Request.QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING. You can determine the number of values of a parameter by calling Request.QueryString(parameter).Count. If a variable does not have multiple data sets associated with it, the count is 1. If the variable is not found, the count is 0.

    So, some things to note:

    In a typical Form on a page, we may include some hidden elements:

    Hidden elements (if memory serves), are not displayed in the QueryString. So, I would assume that there are some things that are not shown in Request.QueryString. Unfortunately I am in the process of re-installing dev apps on a new machine and cannot test this at the moment but if I'm right, when you POST a form, more details about the form and its contents gets sent. And when you access QueryString, you are only seeing the things that make up the entirety of the URL, e.g.:

    http://somesite.com/index.html?v=1&NonHiddenElement=lol&ManualValue=hello

提交回复
热议问题