Learning ASP. NET (2.0 as an example) series from 0 -- 05WEB requests and the survival and death of an ASP. NET Request

Source: Internet
Author: User
Tags file transfer protocol

Introduction:

 

The content in this blog may be a bit obscure, and the description of BlogBoy is not comprehensive enough (in fact, this requires readers to constantly explore and investigate ). However, BlogBoy still believes that it is absolutely capable of fully understanding the majority of the content involved in the length with the wisdom of the big family. OK. Let's talk about the WEB. we have to mention the Internet when talking about the WEB, A large computer network composed of multiple computers in the world. The prerequisite for limiting or forming the Internet is that these computers must follow the TCP/IP protocol family. Therefore, you must understand the WEB andWEB Request ModelFirst, let's take a look at what is TCP/IP and why we need to use this protocol family to establish a network connection.

First, you need to understand that TCP and IP (note that TCP is not a TCP/IP protocol, but a TCP protocol at the transport layer, and an IP protocol at the network layer,TCP/IP protocolThe layer that contains the TCP and IP protocols) is divided into two layers of different protocols, they work together to complete part of the network connection. What is the TCP/IP protocol used?Layer-4 Model(More specific concepts about computer networks andOSIIf you are confused about the layer-7 Reference Model and other related knowledge, you need to spend some time to read it.) Many readers may wonder about these concepts. What is layer, where is the layer? Why do you need to understand these things! BlogBoy believes that some understanding of these layers will help us understand basic network communication mechanisms and the basic knowledge of high-level applications, such as uploading emails and files ...... These functions are frequently used in WEB applications. Understanding TCP/IP helps us understand the basic principles of these applications.

 

 

Body:

 

First, let's take a look at TCP/IP-related knowledge. Why should we understand the layer structure of TCP/IP and the various protocols in each layer! BlogBoy said, because they are the foundation of the Internet and the foundation of all WEB programs.

  • TCP/IP:

1. Network Interface Layer:Define various requirements and features of a physical device, receive IP datagram, and send the datagram to the network IP layer. Undoubtedly, it is the bottom layer of the TCP/IP Layer 4 model.

2. Network IP layer:It is the layer of the IP protocol and the layer responsible for communication between computers. This layer processes requests from the upper transmission layer and accepts data packets from the interface layer. It is the destination of the data packets, it can process datagram requests, input datagram, process runoff, congestion, and other problems.

3. Transport Layer:The layer to which the TCP and UDP protocols belong, providing reliable communication between applications.

4. Application Layer:This layer contains a wide range of user-oriented services, including some of our common applications, suchHTTP(Hypertext Transfer Protocol ),POP3(Post Office Protocol for receiving emails ),SMTP(Simple Mail transmission protocol, used to control the sending and transfer of letters ),FTP(File transfer protocol, used for upload and download ),TELNET(Remote login service ),DNS(Domain name resolution service, used for mutual conversion between URLs and IP addresses, commonly used websites)

  • HTTP Request Response Model:

HTTP belongs to the TCP/IP protocol application layer. Based on this protocol, we request a URL from the browser each time (you can think of it as a resource distributed on a remote host ), an HTTP request is sent. After DNS conversion, the server of the corresponding IP address returns a packet (this packet does not directly contain pictures, files, sounds, visual screens, and so on, instead, it contains URLs for these items. That is to say, the more images or files requested on the webpage, the more requests are requested, because each URL will be requested one by one in subsequent browser processing, this is why many SEO companies advocate the use of CSS genie, merge files, and other optimization methods when doing page optimization. However, these are post-words. Let's take a look at the basics first !), When the page request is received and returned to the browser, an HTTP request will end (we can still see that the content of the page does not disappear while refreshing it will be lost, because the real significance of refreshing is to resend the request ).

  • ASP. NET Request model:

Whether it is ASP. NET, ASP, PHP, and JSP page requests are all variants of HTTP requests. When we type an ASP. NET page URL, and then press enter, you need to go through this process. Let's take a look at the illustration of the request and response on a common ASP. NET page (you can't see it, you can download it, and watch it with professional graphic software ):

Readers need to remember the following objects for the time being, because they are often mentioned or used in later applications:HttpApplication(ASP. NET Program ),HttpContext (Request context ),HttpRuntime(HTTP runtime ),HttpRequest(HTTP request ),HttpResponse(Request accordingly ),HttpHandler(Request Processing Program ).

It is worth noting that IIS and ISAPI are not mentioned in, so I have to say that this is a defect because ASP is discussed out of IIS. NET requests and responses are too abstract, but readers can find many related topics on the Internet. NET Server Control advanced programming also has a very good description.

  • Some events in the lifecycle of the ASPX page:

1. PreInit:Check the IsPostBack attribute to determine whether to process the page for the first time, create or recreate the dynamic settings master page, dynamically set the master page, dynamically set the Theme attribute, read or set the configuration file attribute.

2. Init:This event is triggered after all controls are initialized and all appearance settings are applied. You can use this event to read and initialize control properties.

3. InitComplete:Triggered by a Page Object. This object is used to process tasks that require initialization;

4. PreLoad:Load the view status for the page and all controls, and then process any sending data included in the Request instance;

5. Load:Handles events caused by page loading;

8. PreRender:Occurs before page content is displayed.

9. SaveStateComplete:The ViewState of the control is saved before the event occurs. All modifications made to the page and control are ignored.

10. Render:Write HTML code to the client output stream

 

 

Conclusion:

 

To grasp ASP. NET request, we first introduced the most basic part, that is, the foundation of Internet and TCP/IP, and then our simplest HTTP request as the starting point, I explained about a URL request, and then I discussed about ASP. NET page request model, which is slightly different from the common HTTP model, because ASP. NET pages are also object-oriented, and IIS parses ASP. NETISAPIFinally, we also list the event list and main usage of an ASP. NET page.

Some readers may think that this content is irrelevant like BlogBoy at first, and it may be difficult to master it. It doesn't matter. There is a process in everything. Please take it easy, after writing this article, we have basically ended the long process of laying the foundation. After four articles are used, we will barely finish it.Focuses on practice and skills, Coming soon! Finally, I still have to say that there is no such thing as gold, and I think it is a good place to learn from. I 'd like to mention it. If it is not good, please filter it out by yourself. Well, let's talk about it, last (true !) Wish you all the best!

Related Article

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.