As A. netProgramStaff, if you only know that Microsoft's server control is used to drag out a beautiful interface, double-click the control, get the event response method, and then write the correspondingCodeThis is far from enough. It is often said that "developers who only drag controls ". In addition, the website developed in this way often has a slow execution efficiency problem, that is, the user traffic is too large, and the browser loading page is too slow. If you look at the source file, you will find a large number of viewstates. Therefore, if we want to become an Asp.net developer, we need to have a deep understanding of the interaction between the server and the browser, and the Asp.net page lifecycle.
Communication between the browser and the server is performed through socket Sockets (we must be clear about this. Otherwise, it would be too bad if we don't know it as a website Developer ). As a hardcore fan of Microsoft, I will only talk about the communication process between the IIS server and the browser here (I am not quite sure about other servers, and I am sorry for the limited capacity ).
As we all know, all the protocols we use now are HTTP, while HTTP is a stateless protocol. So what is a stateless protocol. In other words, after a user sends a request to the server through a browser, the browser does not remember who the current user is and who wants the browser to send a service request to the server (then, some friends may say, why do I use a browser to view the next page? This is something that many friends have not figured out. This is what the browser caches for users, instead of caching pages through HTTP, note that !), After the browser presents the data returned by the server to the user, the HTTP protocol will be automatically disconnected and will not work for the user all the time, because the server resources are very valuable, the socket that listens to this request will be released immediately, and then listen to the next request!
After the browser sends a request to the IIS server, the browser sends a long string of request packets to the server. These request packets contain quite useful information. See the following ~ '
GET/zt2011/ZK/no6.htm? Pgv_ref = aio http/1.1
Accept: image/GIF, image/JPEG, image/pjpeg, application/X-MS-application, application/vnd. MS-xpsdocument, application/XAML + XML,
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0; Server Load balancer ;. net CLR 2.0.50727 ;. net CLR 3.5.21022 ;. net CLR 3.0.30729; infopath.2 ;. net CLR 3.5.30729 ;. net4.0c ;. net4.0e; boie9; zhcn)
Accept-encoding: gzip, deflate
HOST: games.qq.com
Connection: keep-alive
After IIS receives these request packets, it will perform a series of parsing,
Mandatory content 1 Request MethodGet
2. Request PathZk/no6.htm? Pgv_ref = AIO
3. Use the Protocol versionHTTP/1.1
4. Request message header contentAccept: image/GIF, image/JPEG, image/pjpeg .......
5 host domain nameHOST: games.qq.com
6. Connection statusConnection: keep-alive
The browser will get the server's impact. The following is the response packet header.
HTTP/1.1 200 OK
Server: nginx/0.6.39
Content-Type: text/html; charset = gb2312
Transfer-encoding: chunked
Connection: keep-alive
Content-encoding: Gzip
The specific meanings of these headers will not be discussed here. Refer to other blog posts ~~
The response style contains a large number of HTML code JS and CSS. I will describe these content in future blog posts! These design pages Control tree generation, more complex.
After the browser obtains the response from the server, the process of sending a request, processing a request, and returning the processing result ends, and the HTTP Protocol completes the process, then the HTTP protocol will not care about what the user does on the page until the user requests again! This is the simplest interaction between the browser and the server!
Okay, this articleArticleNow, the lifecycle of the Asp.net page is over. Thank you ~~~~~