Several days ago, ASP. NET form submissions _ url passing value _ redirection & lt; 18 & gt;, asp.net _ url

Source: Internet
Author: User

Several days ago, ASP. NET form submissions _ url passing value _ redirection <18>, asp.net _ url

I. note when submitting a form

If the data is submitted in get mode, the QueryString method is used for receiving the data.

If the Form is used to receive the post request data

Why? Can we receive data in the form of Request?

--- "If a user sends data in a get request when submitting a Form, the user cannot receive data using the Form,

When a post request is submitted, QueryString cannot receive data. We found that the get request submits data such as text boxes.

Put the content in the url address bar for submission, that is, add the content to the end of the request file in the request header,

THE post request puts the content in the Request Message style,

Test showed that QueryString could not read the content in the Request Message style but could read the content in the url,

Form is able to read the content in the Request body. The content in the url request header cannot be read.

When submitting a form, we usually set the method attribute of the form to post (secure, big data can be passed)

In this case, the value of each element in the form meeting request is sent to the server in a style,

The server receives the message through context. Request. Form. Therefore, the name attribute must be added to the Form element.

Note that the application that hides a field is also a form element, but the effect of this element cannot be seen in the browser,

However, when you click the submit button (post request), the value of the value Attribute of the hidden Tibetan domain will also be submitted to the server,

Then, the server also receives the message through Request. Form,

In the 'compute' applet, we use it to determine whether the user has clicked the submit button to identify it.

2. Redirection

Context. Response. Redirect ()

The Response Header returned by the server contains a 302 response code and a Location attribute,

Then, the browser finds the 302 logo redirection and determines the page to which the Location Property points.

1) context. Response. End () stops execution, and no code will be executed after this statement.

2) Notes:

Which form elements can be submitted to the server and which attributes will be submitted to the server?

Readonly/disabled: Both readonly and disabled are only two-read,

The difference is that readonly will submit the value to the server, while disabled will not

After clicking the submit button, the browser extracts the value from the text box and other controls that the user entered and sends it to the server,

Instead of the server to read the Page entered by the user. Which labels will be submitted to the server?

To submit the content entered by the user to the server, the following conditions are met:

It can only be input, textarea, or select tags. Only input (text box, CheckBox, etc.) users can enter the value,

<Label>, <p>, <font>, and other labels are only for display. They are not required to be submitted to the server.

Only the value of the value attribute is submitted to the server. Take the input tag as an example. The input tag has attributes such as title, type, and disabled,

However, these attributes are for display and cannot be modified. Only the value attribute is the attribute entered by the user,

Therefore, only the value of the value attribute is submitted to the server.

The name attribute must be set for the tag. When learning Dom, we know that if we want to use JavaScript to operate tags,

The Id must be set for the tag. To submit the value Attribute value of a tag to the server, you must set the name attribute for the tag.

When submitted to the server, it will be submitted to the server in the form of "name = value" key-value pairs. Multiple key-value pairs are separated.

Except for a few tags such as single-choice buttons, the name values of most tags cannot be repeated. Name is for the server,

Id is used for Dom. For RadioButton, the same name is a group, and the value of the selected RadioButton is submitted to the server.

If the disabled property of the control is set, the browser does not submit the value of the control. This is different from readonly.

Put it in the form label. Only labels placed in the form label can be submitted to the server, and other labels outside the form are ignored.

Knowledge Point

1) url-based value transfer

// Url-based value transfer

Context. Response. Write ("<a href = 'myfirst. ashx? Name = James & pwd = 12345 '> Haha </a> ");

A get request will be submitted to the server when values are passed through the url. The get request puts the content submitted such as the text box in the url address bar for submission,

This is to append the content to the end of the request file in the request header.

On the server side, you can use context. Request. QueryString to receive

2) redirection

// Redirect

Context. Response. Redirect ("Login. ashx ");

3) Hide the domain

<Input type = 'ddn' value = 'true' name = 'postback'/>

This label is not displayed on the browser,

When a user clicks the submit button in the form to send a post request, the content of the value in the hidden label is submitted to the server,

Then we can

Determine whether the browser submitted a get request or a post request.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.