Asp. NET General Site Handler Basics

Source: Internet
Author: User

Site process: request--processing--response

New--Project--web--asp. NET empty Web application (recommended)

Add generic handler, ASHX format

Where ProcessRequest is the appropriate function for the request

Content. Response.contenttype= "text/html"; Determining the response content type

String Action=context. request["name"];//requests the client to enter the name value and assign it to the server side, and the parameter value obtained by request is a string type

Content. Response.Write ("<font color= ' Red ' >hello World" =action+ "</font>"); response

Form submission

With the <form> tag, the action attribute is submitted to which page, method has get and post two, you need to specify the Name property in HTML for the submission.

The browser submits data to the server side, the form of the submitted data (input, select, Textare, and so on) into the form, and the form is submitted to that page through the Action property, in order to remove the form items from the server side, You need to set the Name property for the form element in HTML, only the value values (input, select, Textare, and so on) are submitted to the server, for RadioButton, the same name as a group, The value of the selected RadioButton is submitted to the server

ID is for JS operation DOM, name is submitted to the server, the entire HTML page ID only one, can not be repeated, name can be repeated

Server side with context. request["username"] to get the submitted property value based on the name of the form item

checkbox is not selected as NULL, checked as "on", tick on, do not tick

method is not safe with get. The content of the post is placed in the form data, the passed form value is hidden in the HTTP message, the URL can not be seen, there is no limit to pass big data, can not be restored through the URL in other users; in get, the content is in query string parameters, What you see in the Address bar is that you pass the form value through a URL, and you can only pass a small amount of data, get the URL data format. Service-side filename followed by "? ", because the client may submit multiple key-value pairs to the server, the key-value pairs are split with" & ", and if there are men and special symbols in the URL, the URL needs to be encoded. In IE, get is seen from the request header, and post is seen from the request body.

HTTP protocol: Is the browser and server-side interaction protocol, the Protocol has a version, the response header represents the server response content, 200 means OK, request-processing-Response 500 Internal server error 302:found temporary transfer, for redirection, Response.Redirect () will ask the browser to request the redirected address again, the redirected request is get, "404" means not Found is not found

Content-type:text/html;charset=utf-8 represents the return data type, which is to tell the client the data type of the response, so that the browser can do different processing based on the return data type, if the picture type is displayed, if it is the text type directly display the content If you use the HTML type to display the content in your browser. This is the reason for setting contenttype in Ashx, if it is plain, directly return the normal text, if it is HTML returned HTML page

HTTP is not to remain connected

HTTP protocol messages

Request:

get/http/1.1 means to request the home page with a GET method to the server, using the http/1.1 protocol

User-agent is the browser version information, this information can be read whether the browser is IE or other

The Referer parameter is the source page.

redirect Redirect request, reply 302 then place the redirect address at location

Context. Response.Redirect ("redirected URLs");

Asp. NET General Site Handler Basics

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.