How to: Create and Configure Virtual Directories in IIS 7.0 (also 6.0)

How to: Create and Configure Virtual Directories in IIS 7.0

.NET Framework 4

By using IIS Manager, you can create a virtual directory for an ASP.NET Web application that is hosted in IIS 7.0. A virtual directory appears to client browsers as if it is in the 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 of the 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 Web site for each virtual directory.

This topic explains how to create a virtual directory and configure it to run ASP.NET pages on versions of that have IIS installed and on Windows Server 2008. For information about how to configure a virtual directory in IIS 5.0, 5.1, and IIS 6.0, see How to: Create and Configure Virtual Directories in IIS 5.0 and 6.0.

You must create a virtual directory as part of an existing IIS Web site. This can be either the default Web site that is created when IIS is installed, or a Web site that you have created. For additional details about how to install and configure IIS and about how to create a Web site, see the IIS Help or the online IIS product documentation on theMicrosoft TechNet  Web site.

Follow one of the procedures in How to: Open IIS Manager topic to open IIS Manager. You can then create a virtual directory.

To create a virtual directory by using IIS Manager

  1. In IIS Manager, expand the local computer and the Sites folder, and then find the Web site that you want to add a virtual directory for. Use the following steps:
    • For , right-click the site or folder where you want to create the virtual directory, and then click Add Virtual Directory.
    • For Windows Server 2008, right-click the site or folder where you want to create the virtual directory, click Manage Web Site, and then click Add Virtual Directory.
  2. In the Add Virtual Directory dialog box, specify the following information:
    • Alias. Type a name for the virtual directory. Choose a short name that is easy to type, because the user types this name to access the Web site.
    • Physical Path. Type or browse to the physical directory that contains the virtual directory. You can select an existing folder or create a new one to contain the content for the virtual directory.
  3. To provide credentials to connect to a UNC path, click the Connect as button.
  4. Click OK.

For more information, see Managing Virtual Directories in IIS 7.0 .

If ASP.NET functionality is enabled, when you create a virtual directory, it is already configured to run ASP.NET pages. For more information about how to enable ASP.NET functionality in IIS 7.0, see Running Web Applications on Windows Vista with IIS 7.0 and Visual Studio or Running Web Applications on Windows Server 2008 with IIS 7.0 and Visual Studio. The next configuration tasks you might want to perform are to configure security and authentication for your virtual directory.

To configure security for a virtual directory for an existing account

  1. In IIS Manager, select the virtual directory that you want to configure, and then click Edit Permissions in the Actions pane.

    The virtual directory’s Properties dialog box is displayed.

  2. Click the Security tab.
  3. Click Edit.

    The Permissions dialog box is displayed.

  4. Select an existing account in the Group or user names list.
  5. Select the appropriate permissions check boxes from the Permissions list for the selected group or user, as required for your virtual directory security.
  6. Click Apply to apply the changes.
  7. Click OK to close the Permissions dialog box.
  8. Click Apply to apply the changes in the Properties dialog box.
  9. Click OK.

To configure security for a virtual directory for an new account

  1. In IIS Manager, select the virtual directory that you want to configure, and then click Edit Permissions in the Actions pane.

    The virtual directory’s Properties dialog box is displayed.

  2. Click the Security tab.
  3. Click Edit.

    The Permissions dialog box is displayed.

  4. Click Add to add an account.

    The Select Users, Computers, or Groups dialog box is displayed.

  5. Add a user, computer, or group as required for you virtual directory security.
  6. Click OK to close the Select Users, Computers, or Groups dialog box.
  7. Select the appropriate permissions check boxes from the Permissions list for the new user, computer, or group, as required for your virtual directory security.
  8. Click Apply to apply the changes.
  9. Click OK to close the Permissions dialog box.
  10. Click Apply to apply the changes in the Properties dialog box.
  11. Click OK.

To configure authentication for a virtual directory

  1. In IIS Manager, select the virtual directory that you want to configure.
  2. In Features View, double-click Authentication.
  3. Select the authentication type to configure, and in the Actions pane make sure Enable is selected in order to enable the authentication type.

    If the authentication type is already enabled, the Actions pane enables you to disable or edit authentication configuration.

  4. In the Actions pane, click Edit or Advanced Settings to configure additional properties for the authentication type you selected.

    The actions available in the Actions pane vary depending on the authentication type you selected. For example, if the Anonymous Authentication module is installed and is enabled, you can click Edit to edit additional properties of anonymous authentication. If the Window Authentication module is installed and is enabled, you can click Advanced Settings to edit properties of windows authentication.

For more information about configuration authentication, see Configuration Authentication in IIS 7.0 . For a list of other common administrative tasks, see Common Administrative Tasks .

Creating Virtual Directories in IIS 6.0 (IIS 6.0)

In most cases, the content you publish to your Web or FTP site is located in a root or home directory on your computer, such as C:\Inetpub\Wwwroot\. However, there might be instances when the content is located somewhere else, or even on a remote computer.

To publish from any directory not contained within your home or root directory, you can create a virtual directory. A virtual directory is a directory that is not contained in the home directory but appears to client browsers as though it were.

You can create a virtual directory through IIS Manager or by using Windows Explorer. Additionally, you can create a Web virtual directory by using the Iisvdir.vbs script, and a FTP virtual directory by using the Iisftpdr.vbs script.

  Important

You must be a member of the Administrators group on the local computer to perform the following procedure or procedures. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run IIS Manager as an administrator. At a command prompt, type runas /user:Administrative_AccountName “mmc %systemroot%\system32\inetsrv\iis.msc”.

Procedures

To create a virtual directory by using IIS Manager

1. In IIS Manager, expand the local computer, expand the Web Sites or FTP Sites folder, right-click the site or folder within which you want to create the virtual directory, point to New, and then click Virtual Directory. The Virtual Directory Creation Wizard appears.
2. Click Next.
3. In the Alias box, type a name for the virtual directory. (Choose a short name that is easy to type because the user types this name.)
4. Click Next.
5. In the Path box, type or browse to the physical directory in which the virtual directory resides, and then click Next.
6. Under Allow the following permissions, select the check boxes for the access permissions you want to assign to your users, and then click Next.

  Important

For security reasons, when selecting access permissions, consider allowing only the default Read permission. By restricting permissions in this way, you can help avoid attacks against your Web site by malicious users. For more information about setting access permissions, see Securing Virtual Directories and Access Control in Help and Support Center for Windows Server 2003.

7. Click Finish. The virtual directory is created below the currently selected folder level.

To create a virtual directory by using Windows Explorer

1. Open Windows Explorer.
2. Right-click the folder you want to be a virtual directory, and click Sharing and Security.
3. Click the Web Sharing tab.
4. Click Share this folder.
5. In the Alias box, type the name for the virtual directory.
6. Click OK twice.

To create a Web virtual directory by using the Iisvdir.vbs script

1. From the Start menu, click Run.
2. In the Open box, type cmd, and then click OK.
3. At the command prompt, type the following:

cscript %SystemRoot%\system32\iisvdir.vbs /create SampleWebSite[/PathVirtualDirectorydrive:\path

where SampleWebSiteVirtualDirectory, and path is the physical directory, as appropriate.

For more information about creating Web virtual directories by using the Iisvdir.vbs command and its parameters, type the following at the command prompt: iisvdir /create /?.

To create an FTP virtual directory by using the Iisftpdr.vbs script

1. From the Start menu, click Run.
2. In the Open box, type cmd, and then click OK.
3. At the command prompt, type the following:

cscript %SystemRoot%\system32\iisftpdr.vbs /create FTPSite[/PathVirtualDirectory drive:\path

where FTPSiteVirtualDirectory, and path is the physical directory, as appropriate.

For more information about creating FTP virtual directories by using the Iisftpdr.vbs command and its parameters, type the following at the command prompt: iisftpdr /create /?.

Leave a comment