Understanding Sites, Applications, and Virtual Directories on IIS 7

转:https://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis

Understanding Sites, Applications, and Virtual Directories on IIS 7

By Reagan Templin

November 23, 2007

Introduction

In IIS, you can create sites, applications, and virtual directories to share information with users over the Internet, an intranet, or an extranet. Although these concepts existed in earlier versions of IIS, several changes in IIS 7 and above affect the definition and functionality of these concepts. Most importantly, sites, applications, and virtual directories now work together in a hierarchical relationship as the basic building blocks for hosting online content and providing online services.

This article provides a quick overview of applications in IIS 6.0 so that you can better understand the differences introduced in IIS 7. It then explains the concepts of sites, applications, and virtual directories in IIS and introduces the<sites> section in configuration.

This article contains:

About Sites, Applications, and Virtual Directories in IIS 6.0

In IIS 6.0, the concepts of virtual directories and applications were confusing. Although they were discussed as separate concepts, (and they were conceptually different from a functionality standpoint), an application was not a physically separate object from a virtual directory. In IIS 6.0, an application was really just a virtual directory with one or a combination of the following properties in the metabase: AppFriendlyNameAppRootAppIsolated, andAppPoolID.

Note: The site root is an exception, as it was implicitly treated as an application even if those properties were not set.

Applications were less important to IIS than to the technologies that extended Web server functionality, such as Active Server Pages (ASP), Internet Server Application Programming Interface (ISAPI), and ASP.NET. These technologies provided additional features and processing for applications hosted in IIS 6.0, and enabled developers to create more complex applications. The important question for IIS 6.0 was isolating such applications in a way that would prevent applications in one application pool from affecting applications in another application pool on the server.

About Sites, Applications, and Virtual Directories in IIS 7 and Above

IIS 7 and above formalizes the concepts of sites, applications, and virtual directories. Virtual directories and applications are now separate objects, and they exist in a hierarchical relationship in the IIS configuration schema. Briefly, a site contains one or more applications, an application contains one or more virtual directories, and a virtual directory maps to a physical directory on a computer.

As in IIS 6.0, a site contains all the content, both static and dynamic, that is associated with that site. However, each site must contain at least one application, which is named the root application. And each application (including the root application) must contain at least one virtual directory, which is named the root virtual directory. These objects work together to form the site.

Additionally, in IIS 7 and above, the concept of an application now has meaning to both IIS and the technologies that extend IIS functionality. An application is an object important to the server at runtime. This is because the IIS and ASP.NET request-processing pipelines have merged in IIS 7 and above so that content can take advantage of functionality previously provided for only managed code applications. For example, each managed code application runs in an Application Domain (AppDomain). An application can have several virtual directories, and each one will be served by the same AppDomain as the application to which they belong.

The following sections explain sites, applications, virtual directories, and their related configurations in more detail.

Sites

A site is a container for applications and virtual directories, and you can access it through one or more unique bindings.

The binding includes two attributes important for communication: the binding protocol and the binding information. The binding protocol defines the protocol over which communication between the server and client occurs. The binding information defines the information that is used to access the site. For example, the binding protocol of a Web site can be either HTTP or HTTPS, and the binding information is the combination of IP address, port, and optional host header.

A site may contain more than one binding if the site requires different protocols or binding information. In earlier versions of IIS, only the HTTP and HTTPS protocols were supported. For example, a Web site might have had both an HTTP binding and an HTTPS binding when sections of the site required secure communication over HTTPS.

In IIS 7 and above, bindings can apply to any protocol. The Windows Process Activation Service (WAS) is the new service that makes it possible for IIS to use additional protocols. This service retains the familiar IIS 6.0 process model, such as application pools and message-based process activation, as well as hosting features, such as rapid failure protection, health monitoring, and recycling. However, WAS removes the dependency on HTTP from the activation architecture. This is useful for technologies that provide application-to-application communication in Web Services over standard protocols. The Windows Communication Foundation (WCF) programming model is one such technology that can enable communication over the standard protocols of Transmission Control Protocol (TCP), Microsoft Message Queuing (MSMQ), and Named Pipes. This lets applications that use communication protocols take advantage of IIS features, such as process recycling, rapid fail protection, and configuration that were previously only available to HTTP-based applications. For more information about the WCF programming model, see Windows Communication Foundation on MSDN.

In addition to containing applications (which contain virtual directories) and specifying bindings, the following configuration settings belong to the site:

  • Limits: configure settings to limit the amount of bandwidth, the number of connections, or the amount of time allowed for connections to a site.
  • Logging: configure settings for handling and storage of log files for the site.
  • Failed request trace logs: configure settings for logging failed-request traces for the site.

Applications

An application is a group of files that delivers content or provides services over protocols, such as HTTP. When you create an application in IIS, the application's path becomes part of the site's URL.

In IIS 7 and above, each site must have an application which is named the root application, or default application. However, a site can have more than one application. For example, you might have an online commerce Web site that has several applications, such as a shopping cart application that lets users gather items during shopping and a login application that allows users to recall saved payment information when they make a purchase.

In addition to belonging to a site, an application belongs to an application pool, which isolates the application from applications in other application pools on the server. In the case of managed code applications, make sure to associate your application together with an application pool that is running the .NET Framework version that your application requires.

As described in the Sites section of this paper, IIS supports HTTP and HTTPS by default, but you can use additional protocols. For each site, you specify one or more bindings to communicate with and access content in the site. For an application to communicate by using a protocol that is specified in the parent site's binding, you must enable the protocol. To do this, specify the protocol in the enabledProtocols attribute for the application, and ensure that you have the appropriate listener adapter on the server and specified in the <listenerAdapters> section in configuration.

Virtual Directories

A virtual directory is a directory name (also referred to as path) that you specify in IIS and map to a physical directory on a local or remote server. The directory name then becomes part of the application's URL, and users can request the URL from a browser to access content in the physical directory, such as a Web page or a list of additional directories and files. If you specify a different name for the virtual directory than the physical directory, it is more difficult for users to discover the actual physical file structure on your server because the URL does not map directly to the root of the site.

In IIS 7 and above, each application must have a virtual directory, which is named the root virtual directory, and which maps the application to the physical directory that contains the application's content. However, an application can have more than one virtual directory. For example, you might use a virtual directory when you want your application to include images from another location in the file system, but you do not want to move the image files into the physical directory that is mapped to the application's root virtual directory.

By default, IIS uses configuration from Web.config files in the physical directory to which the virtual directory is mapped, as well as in any child directories in that physical directory. If you do not want to use Web.config files in child directories, specify false for the allowSubDirConfig attribute on the virtual directory.

Optionally, when you need to specify credentials and a method to access the virtual directory, you can specify values for the usernamepassword, and logonMethod attributes.

IIS Configuration: <sites> Section

Take a look at the default <sites> section in IIS 7 and above. This is what is in the ApplicationHost.config file (located at %windir%\system32\inetsrv\config \) after installing IIS on Windows Server® 2008.

<sites> 
<site name="Default Web Site" id="1"> 
<application path="/"> 
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" /> 
</application> 
<bindings> 
<binding protocol="http" bindingInformation="*:80:" /> 
</bindings> 
</site> 
<siteDefaults> 
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" /> 
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" /> 
</siteDefaults> 
<applicationDefaults applicationPool="DefaultAppPool" /> 
<virtualDirectoryDefaults allowSubDirConfig="true" /> 
</sites>

When you see a single "/" in a path field, you know that this is a root object. Depending on whether it is in the application or virtual directory section, it is a root application or a root virtual directory.

Default Elements

The following section lists the collections and elements in the <sites> section, and their hierarchical relationship within the <sites> section.

<sites> section 
<site> collection 
<bindings> collection 
<binding> element 
<clear> element 
<limits> element 
<logFile> element 
<traceFailedRequestsLogging> element 
<application> collection 
<virtualDirectory> collection 
<virtualDirectoryDefaults> element 
<applicationDefaults> element 
<virtualDirectoryDefaults> element 
<siteDefaults> element 
<bindings> collection 
<binding> element 
<clear> element 
<limits> element 
<logFile> element 
<traceFailedRequestsLogging> element 
<applicationDefaults> element 
<virtualDirectoryDefaults> element

Notice that there are two elements that appear in more than one place: the <applicationDefaults> element and the <virtualDirectoryDefaults> element. There is also a <siteDefaults> element, although it appears only once because it can be configured in only one location in the <sites> section. Default elements are special because they enable you to configure default values for attributes instead of having to repeat the same values in each collection.

When an attribute is configured at more than one level, the value at the lowest level is used. For example, if you specify a default value in an <applicationDefaults> element in both the <sites> section and in a <site> collection, the value from the <site> collection will be used. Additionally, if the same attribute or child element is configured in both a default element and in the object's collection, the value in the collection will be used. For example, if you configure an attribute in an <applicationDefaults> element and in an <application> collection, the value from the <application> collection will be used.

The following table specifies under which parent elements an <applicationDefaults> element can be configured, and describes the effect that the values have on applications.

Parent element

Description

<sites> section

Specifies the default settings for all applications on the server.

<site> collection

Specifies the default settings for all applications in the parent site.

The following table specifies under which parent elements a <virtualDirectoryDefaults> element can be configured, and describes the effect that the values have on virtual directories.

Parent element

Description

<sites> section

Specifies the default settings for all virtual directories on the server.

<site> collection

Specifies the default settings for all virtual directories in the parent site.

<application> collection

Specifies the default settings for all virtual directories in the parent application.

Summary

You should now have a better understanding of sites, applications, and virtual directories in IIS 7 and above. Unlike IIS 6.0, applications and virtual directories have become distinct objects in configuration, which highlights their unique purpose to the Web server and their relationship to the site. Additionally, sites can now contain applications that use protocols other than HTTP and HTTPS, which extends site functionality while retaining the benefits of the process model introduced in IIS 6.0.

For more information about WAS and IIS architecture, see IIS Request-Processing Architecture on IIS.NET. For more information about the configuration settings discussed in this article, see IIS 7 Settings Schema on MSDN.

By Reagan Templin


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值