Asp.net notes

Source: Internet
Author: User

1. Difference Between get and post

Get explicitly transmits parameters through URL, and the parameter transfer length is limited.

Implicit post transfer, which can transmit large data volumes

2. A form can only submit values of input, select, and textarea with name.

For those that cannot submit value, such as Div. It can be transferred with the hidden type input instead. This is the origin of ASP. NET's viewstate mechanism.

3. A large amount of data cannot be stored in den or viewstate, which increases the upload traffic and slows down the webpage. At the same time, the form cannot store confidential data, which may cause data spoofing.

4. The background variable cannot save the value of B. The session mechanism and cookie are referenced for this variable. Session is the correspondence between user information on the B end and memory on the S end. Cookie saves the information data locally. The session cannot store too much data and will be automatically cleared after a period of time. For example, if you edit an article online for a long period of time, the article cannot be submitted, timed out, or lost. Optimization case: the Domain Name of the website's main site is separated from the domain name of the music station, image station, and other large-volume sub-stations, to prevent the massive submission and update of cookies.

5. Each request will be processed by a new instance of the class implementing the ihttphandler interface. The GC will not be retained after use.

6. js can be used as client-side verification to facilitate users. However, if Javascript is disabled, it may cause unnecessary troubles. Therefore, data restrictions and other functions must be processed on the server.

7. In the <asp: button> label, onclientclick indicates a client Click Event, and onclick indicates a server click event.

8. virtrualpathutility:

Toabsolute ("~ /Ex. aspx ") convert the virtual path ~ /Ex. aspx to absolute path

Appendtrailingslash ("") determines whether or not the virtual path has a/. If not, add

Combine ("", ") merges two paths. Note that if there is no/at the end of Path 1, find the last path and merge it. For example, combine (" ~ /A/bits, ”c.html ") merged ~ /A/c.html

9. Response object:

Buffer: cache allowed

Flush: immediately sends the content in the cache area to the browser, which is usually used for step-by-step output.

Clear: clears the buffer.

End: Terminate the request. The request is not followed by the Code.

Redirect: redirection. the browser accesses the new website, so the address bar changes. Sends two messages to notify users of access and access.

Outputstream: output stream, such as Excel and Image

Setcookie: Set cookie

Writefile: directly output the file to the browser

10. In the example of outputting non-HTML with aspx, we often see using clear to output additional content such as httpmodule. Therefore, it is not recommended to use aspx to output non-HTML files. (Use ashx)

11. Request object:

Apprelativecurrentexecutionfilepath: relative path of the current page

Physicalapplicationpath: physical path of the current application

Physicalpath: physical path of the current page

Urlreferrer: webpage source for anti-leech Protection

Userhostaddress: obtains the visitor's IP address.

Userages: Obtain the Supported languages of the visitor's browser.

COOKIE: Read cookie

12. Server Object:

Transfer: Switch inside the server, which is taken over by other aspx pages. The browser address remains unchanged. Cannot be redirected to an external website. There is only one request. And cannot be redirected to ashx

Httpcontext: Sometimes the httpcontext object cannot be obtained directly, and it must be obtained using httpcontext. Current.

13. httphandler

Use response. addheader () to add the packet header.

Content-Disposition: attachment; filename = *. * is used as the download link.

If the filename contains Chinese characters, use httputility. urlencode () encoding first.

14. The irequiressessionstate interface must be implemented when session is used in ashx.

15. When creating an Asp.net project, do not include the # symbol in the folder to avoid parsing path errors.

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.