Compartilhar via


How to: Create and Configure Virtual Directories in IIS 

Using Internet Information Services (IIS) Manager, you can create a virtual directory for an ASP.NET Web application. A virtual directory appears to client browsers as though it were contained in a Web server's root directory, even though it can physically reside somewhere else. This approach enables you to publish Web content that is not located under the root folder on your Web server, such as content that is located on a remote computer. It is also a convenient way to set up a site for local Web development work because it does not require a unique site identity, which means that it requires fewer steps than creating a unique site. This topic explains how you can create a virtual directory and configure it to run ASP.NET pages.

To create a virtual directory, a Web site must already be created on the Web server. IIS creates a default Web site on the computer during installation. If you have not created a site of your own, you can create a virtual directory under the default Web site. For additional details about installing and configuring IIS, or creating a Web site, see the IIS Help documentation that is included with the product or the online IIS product documentation on the Microsoft TechNet Web site.

As an alternative to creating a virtual directory for your Web application, you might want to create a new Web site with a unique identity. For details about creating a Web site in IIS Manager, see How to: Create and Configure Local ASP.NET Web Sites in IIS.

Starting IIS Manager

First, you need to start the IIS Manager.

NoteImportant

You must be logged on as a member of the Administrators group on the local computer to perform the following procedure (or procedures), or you must have been delegated the appropriate authority.

To start IIS Manager from the Run dialog box

  1. On the Start menu, click Run.

  2. In the Open box, type inetmgr and click OK.

To start IIS Manager from the Administrative Services console

  1. On the Start menu, click Run. In the Run text box, type control panel, and then click OK.

  2. In the Control Panel window, click Administrative Tools.

  3. In the Administrative Tools window, click Internet Information Services.

Creating the Virtual Directory

Now that IIS Manager is started, you are ready to create a virtual directory.

To create a virtual directory by using IIS Manager

  1. In IIS Manager, expand the local computer and the Web site to which you want to add a virtual directory. Right-click the site or folder within which you want to create the virtual directory, point to New, and then click Virtual Directory.

  2. In the Virtual Directory Creation Wizard, click Next.

  3. In the Alias box, type a name for the virtual directory and then click Next. Choose a short name that is easy to type, because the user types this name to access the Web site.

  4. In the Path box, type or browse to the physical directory that contains the virtual directory, and then click Next. Note that you can select an existing folder or create a new one to contain the content for the virtual directory.

  5. Select the check boxes for the access permissions that you want to assign to your users. By default, the Read and Run Scripts check boxes are selected; these permissions enable you to run ASP.NET pages for many common scenarios.

  6. Click Next and then click Finish.

Configuring the Virtual Directory

After creating a new virtual directory, you can configure it to run ASP.NET pages and configure security. The following table shows the permissions settings that are available in all versions of IIS, including IIS 6.0.

Account or Group Permissions

An account or group that you choose to give browse access to the site if you disabled anonymous authentication when you created the virtual directory.

Read & Execute

The account configured to access system resources for the ASP.NET current user context, such as the Network Service account (IIS 6.0) or the ASPNET account (IIS 5.0 and 5.1).

Read & Execute

List Folder Contents

Read

Write

When you are finished configuring the virtual directory, you can then add ASP.NET Web pages to the physical directory that is associated with the virtual directory. For more information, see Configuring ASP.NET Applications.

To configure security and authentication for a virtual directory

  1. In IIS Manager, right-click node for the virtual directory that you want to configure, and then click Properties.

  2. Click the Directory Security tab, and then in the Authentication and access control section, click Edit.

  3. Select the check box for the authentication method or methods that you want to use for your virtual directory, and then click OK. By default, the Enable anonymous access and Windows Integrated Authentication check boxes are already selected.

    NoteNote

    The two most common authentication scenarios are to use Windows Integrated authentication for a local intranet site, or to use Forms authentication for an Internet or extranet site where users access the site through a firewall. To configure authentication for an intranet or local development scenario, clear the Enable Anonymous access check box, and make sure the Integrated Windows authentication check box is selected. To configure authentication for an Internet site, you need to set up Forms authentication, which is beyond the scope of this topic. For more information about authentication options, see ASP.NET Authentication. For a walkthrough that describes how to create a site using Forms authentication, see How to: Implement Simple Forms Authentication.

  4. In Windows Explorer, navigate to the folder that will contain the pages for the site. Right-click the folder and then click Sharing and Security on the shortcut menu.

  5. On the Security tab, configure any additional accounts and permissions that you need, and then click OK.

    NoteNote

    To change permissions for an existing account, select the account in the Group or user names list, and then select the appropriate permissions check boxes. To add a new account, click Add, and then click the Locations button. Select the local computer name from the list and click OK. Then type the particular account name that you want to add into the text box. After typing in a name, click Check Names to verify the account name, and finally click OK to add the account.

See Also

Tasks

How to: Create and Configure Local ASP.NET Web Sites in IIS
How to: Implement Simple Forms Authentication

Other Resources

Configuring ASP.NET Applications
ASP.NET Authentication