IIS schema and HTTP request processing flow

Source: Internet
Author: User
Tags metabase



IIS schema and HTTP request processing flow



IIS in the Windows operating system is responsible for providing internet services, and a computer running IIS can be viewed as a Web server.



The IIS major version number in Windows XP SP2 is 5,windows 2003 server is 6,vista and Windows Server 2008 is 7. For Windows 2003 Server, which is supported by default, the ASP. NET version is 1.1, so you have to install the version 2.0 or above separately [1].



Currently, IIS 6 is the most widely used version, IIS 5 is largely not deployed on a Web server, IIS 6 differs significantly from the system architecture compared to IIS 5, and IIS 7 has no fundamental changes to the underlying architecture compared to IIS 6, but there are new enhancements and improvements in many areas. This book is described in IIS 6/7 and most of the content is also appropriate for IIS 5, but some outdated features of IIS 5 are not covered.



First, let's take a closer look at the three basic concepts that are easy to confuse.



8.1.1 Web sites, Web applications, and virtual directories



In IIS, you can create Web sites, Web applications, and virtual directories to share information with users on your computer network. 






In short, a Web site contains one or more Web applications (Web application), one Web application contains one or more virtual directories, and the virtual directory is mapped to the Web The physical directory on the server or remote computer.




There are two sites on this Web server: Default Web site and Newwebsite, where there are three "Web applications" in the Default Web site: Happybookshopservice, Happybookshopwebsite and Onlinealbum. Each sub-folder under the Happybookshopwebsite application is a "virtual directory". The top-most virtual directory is called the "root virtual directory".


Each of these three concepts is analyzed below.


1 website (web site)


A site is a container for Web applications, each with a unique identity, which is composed of its IP address, port, and optional host/host name . The Web server determines which Web site is requested based on this information in the HTTP request received.



In IIS 7, the site identity is called site binding.


2 Web application (Web application)


A WEB application is a software program that runs in an application pool (application pool) [3] and provides information services (usually in HTML format) to the user through the HTTP protocol. When you create a Web application, the name of the Web application becomes part of the site URL, and the user can issue an HTTP request for that URL through a Web browser.



ASP created by using Visual Studio. NET Web site is, in fact, a "Web application" that does not equate to "Web sites" in IIS.



In IIS, each Web site must have at least one Web application (but not necessarily an ASP. NET application, which can be another type of Web application), which is referred to as the " root Web Application" or " default Web application, in addition, a Web site can contain one or more ASP. NET (or other kinds of) Web applications.



In Windows XP SP2, the ASP. NET Web site created with Visual Studio is published to native IIS and runs as a Web application hosted by the native Default Web site, which is the Web site represented by "localhost".



Windows server and Vista can create a standalone IIS Web site for an ASP. Web application that hosts only this unique ASP. NET application and runs in a separate application pool. Many commercial web sites use this approach to achieve higher performance, while isolating the Web site from other sites hosted on the Web server to enhance the security of the Web server.


3 virtual directory (Vsan)





A virtual directory is a directory name that is specified in IIS and mapped to a physical directory on a local or remote server. The virtual directory name will then become part of the Web application URL, and users can request access to IIS for resources in the physical directory corresponding to this URL through a Web browser.



In IIS, each WEB application must have a top-level virtual directory, which is referred to as the " root virtual directory ."



In Visual Studio, you can directly set the root "virtual path" of an ASP. NET Web site in the Properties window.




Note, however, that the "virtual path" Set here is the virtual path of the Lightweight Web server "ASP. Development Server" that comes with Visual Studio, not the virtual path in IIS. If you are using the full version of Visual Studio (such as team development), you can use a publishing site feature. When you publish a Web site using this feature, you can directly specify the root virtual directory map  that the ASP. NET application corresponds to in IIS.




A Web application can have multiple virtual directories that become subdirectories of the Web application root virtual directory.



It is convenient to create a virtual directory in IIS .






After you add a virtual directory to your Web app, you can access the Web pages in the virtual directory by using the following URL






HTTP//Site name/web application root virtual directory/newly created sub-virtual directory/web page name






In the example above, the Web application root virtual directory is "/mynewwebsite" and the newly added virtual directory is "Mynewvirtualdir", which points to the "D:/mydir" directory. Now that you have an ASP. NET page in the D:/mydir directory (which may be set to sample.aspx), you can access this page from the following URL:






Http://localhost/MyNewWebSite/MyNewVirtualDir/Sample.aspx



[1] It is recommended to install the latest version of the. NET Framework on Windows 2003 server to support some new technologies such as Ajax and Silverlight.


[2] More specifically, it is a system core component of Windows Server: HTTP. SYS is responsible for this work. The HTTP. SYS component is also described later in the introduction of the IIS schema.


[3] The following article describes the application pool in more detail



[4] "virtual directories" are sometimes referred to as "virtual paths", both of which represent the same concept.



[5] For Visual Web Developer Express, it does not provide a "publishing site" feature, but it can be done by locating the appropriate button in the Copy Web Site dialog window. Or, more directly, use IIS Manager to do this work.



[6] In IIS 5/6, use the Virtual Directory Creation Wizard to create a virtual directory by right-clicking on one of the Web application nodes in IIS and selecting the "New"-"virtual directory" command from the shortcut menu. The operation of IIS 7 is similar, but it provides the command "Add virtual directory" directly in the first level of the shortcut menu.



8.1.2 application pool and worker processes






Application Pools (applicaionpool)is a Web program isolation mechanism introduced by Windows Server to improve the performance and reliability of Web services.



An application pool can contain one or more Web applications. The ASP. NET Web application must be running in an application pool.



In Windows Server, one or more worker processes (worker process)serves application pools, and stopping an application pool will cause these worker processes to be shut down, All HTTP requests destined for Web applications in this application pool will receive a "503 Service Unavailable" response.







 3 application pools are set up on this Web server, and multiple Web applications can run in each application pool, and 5 Web applications are running in the DefaultAppPool application pool. Each application pool can load a specific version of the. NET Framework to provide support for ASP. In IIS 7, the application pool has two modes of operation- Classic and integrated .



In Classic mode, the IIS7 application pool runs in the same way as IIS 6 [1].



In Integrated mode, IIS 7 directly preload the. NET Framework to provide better performance for ASP.



An application pool can be started and stopped at any time in IIS Manager.



The system account that runs the application pool on Windows server is "NetworkService". As you can see in later chapters, you often need to set specific permissions to this account when you deploy an ASP (such as allowing an ASP. NET application to add files to a folder).



Here's an in-depth look at the system architecture of IIS and how Windows Server responds to HTTP requests.






8.1.3 System Architecture for IIS


The IIS 6 architecture consists of the following parts:



(1)http. SYS: A component running in Windows core (Kernel) that listens for (Listen) HTTP requests from outside (usually from a browser on another computer on the network). It is forwarded to the appropriate application pool based on the URL of the request, and the worker process running in the application pool responds to this HTTP request. When this HTTP request processing is complete, it is also responsible for sending the processing results (the recipient is usually the browser that makes the HTTP request).



In order to provide better performance, HTTP. SYS internally establishes a buffer that stores the results of the most recent HTTP request processing, and if an HTTP request is found to have been processed "not too long ago" (that is, it can be found in the buffer), it simply takes the results out of the buffer and sends it back to the client (usually the browser that makes the HTTP request).



(2) InetInfo: In the IIS 5 era, InetInfo is the main process of the IIS service, and in IIS 6 it is no longer responsible for processing HTTP requests, but it continues to be responsible for managing other Internet services in addition to the WWW service. For example, FTP service for file transfer and SMTP service for mail sending and receiving.



Inetinfo maintains a meta-database (Metabase), which stores important information in this database, which is essential for maintaining various internet services such as WWW and FTP.



(3) Workerprocess: responsible for handling HTTP requests, translated as " worker Processes ", in fact, it is a process generated by an executable program W3WP.EXE runtime [2] , one or more ASP. NET applications can be managed within each worker process . worker processes run in an application pool (application pool). IIS 6 can create multiple application pools and specify an ASP. NET application to run in a particular application pool .






In general, an application pool has only one worker process, but it is also possible to configure the necessary parameters to allow multiple worker processes to run concurrently in the same application pool, in which case the application pool is called theWebgarden(web Park)".



(4) was (Web Admin Service ): This is a monitoring program that allows access to various information placed in the Inetinfo metabase (Metabase), and also monitors the working status of worker processes in the application pool (application pools), If necessary, it shuts down an old worker process and creates a new one instead.




[1] After the application pool is run in IIS 6, the following article is described in detail



[2] "process" is a program with a certain independent function on a data set on a dynamic execution process. If expressed in popular language, the "process" can simply be understood as a running program.



8.1.4 Processing of HTTP requests






After understanding the architecture of IIS, take a look at how the various components of the IIS schema work together to handle HTTP requests.



Let's take a look at the process of HTTP requests in general 


 HTTP request processing is the "one-answer" process between the browser and the Web server.



First, the browser tries to connect to port 80 of the Web server, and if the Web server responds to this connection request, it establishes a communication link between the browser and the Web server, where the browser and Web server can send and receive information to each other.



Suppose the browser issues a request to the Web server to read an ASPX page on an ASP. When this request reaches the Web server over the network, this request is received by the HTTP. SYS component. HTTP. SYS system component examines information about this HTTP request and sends this HTTP request to the worker process running in an application pool based on its URL. If there are multiple HTTP requests for this ASP. SYS, it queues these requests and joins them in the HTTP request queue for the corresponding application pool.



If this is the first HTTP request to an ASP. NET site, the worker process loads the aspnet_isapi.dll and forwards the request to it, aspnet_isapi.dll then loads . NET CLR[1] , create an application domain for this ASP. NET site [2] , and then start a complex processing process involving multiple steps and components, and when this process is finished, the results to be sent back to the client (usually HTML code, and of course other types of resources, such as a picture generated dynamically by the program) have been generated, and this result is forwarded to HTTP. sys.



Note: for IIS 7,.net that run in Integrated mode, the CLR automatically mounts as soon as the application pool is started, thus avoiding the overhead of temporarily loading the CLR. The subsequent process is basically consistent with IIS 6.



HTTP. SYS receives the processing result of the request, caches it into the buffer, and sends the processing results back to the browser that made the HTTP request.



The above procedure is a rough description of the entire process of handling HTTP requests by IIS. Section 8.2 will select the main phases of this process, detailing the HTTP request processing for ASP.




8.1.5 ISAPI extensions, ISAPI filters, and program mappings









Two terms are often mentioned in the documentation for IIS: ISAPI extensions and ISAPI filters.


1 ISAPI Extensions


AnISAPI Extension (ISAPI Extension)is a program that can be added to IIS to enhance the functionality of the Web server, and its vectors are DLL files. It is usually directly responsible for responding to HTTP requests.



Depending on the name of the resource extension to be accessed by the HTTP request (obtained through a URL), IIS chooses a specific ISAPI extension to handle the request, a process known as " program mapping ". This ISAPI extension, which responds to HTTP requests, is referred to as an "http Handler(http handler)". 





IIS specifies that the request to an ASP. NET Web page (which has an. aspx extension) will be processed by Aspnet_isapi.dll .






The program mappings in IIS 7 are slightly different from IIS 6. When IIS 7 is running in Classic mode, the Aspnet_isapi.dll response to requests for ". aspx" is used in the same way as IIS 6. However, when IIS 7 is running in Integrated mode, the managed handler (System.Web.UI.PageHandlerFactory) is used to respond to requests for ". aspx" .






2 ISAPI Filters


ISAPI Filters (ISAPI filter) " is also a DLL, but it is not responsible for generating HTTP requests, its primary function is to respond to certain specific events. When these events occur, the ISAPI filter is called, and it can modify incoming or outgoing HTTP data.



In IIS 7, the functionality of traditional ISAPI filters has been superseded by the use ofhttp module (HTTP modules) .



Note: The ISAPI extension is similar to the ISAPI filter name, but its status and role in IIS is different.




[1] CLR (Comon Language Runtime): The common language runtime, the core of. NET, can be seen as a virtual dedicated to run. NET program to the computer.



[2] application domain (application domain): A code isolation mechanism introduced by. NET, a managed process can have multiple application domains, can mount assemblies in an application domain, create objects of a specific type, and invoke methods of objects.



IIS schema and HTTP request processing flow


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.