Setting Up Internet Information Services and ASP.NET - Managing Websites
(Page 2 of 5 )
To add more pages to your web server, you can copy HTML, ASP, or ASP.NET files directly to the c:\Intetpub\wwwroot directory. For example, if you add the file TestFile.html to this directory, you can request it in a browser through the URL http://localhost/TestFile.html. You can even create subdirectories to group together related resources. For example, the file c:\Intetpub\wwwroot\MySite\MyFile.html can be accessed through a browser using the URL http://localhost/MySite/MyFile.html. If you’re using Visual Studio .NET to create new web projects, you’ll find that it automatically generates new subdirectories in the wwwroot directory. So if you create a web application named WebApplication1, the files will be stored in c:\Inetpub\wwwroot\WebApplication1, and made available through http://localhost/WebApplication1.
Using the wwwroot directory is straightforward, but it makes for poor organization. To properly use ASP or ASP.NET, you need to make your own virtual directory for each web application you create. With a virtual directory, you can expose any physical directory (on any drive on your computer) on your web server, as though it were located in the c:\Inetpup\wwwroot directory.
To create virtual directories, you need to use the administrative Internet Information Services utility. To start it, select Settings -> Control Panel -> Administrative Tools -> Internet Services Manager from the Start menu on the taskbar. The next few sections walk you through the steps and explain the settings that you can configure.
NOTE This chapter is written with IIS 5 in mind. Both Windows 2000 and Windows XP use IIS 5. However, if you’re programming on Windows 2003 Server, you’ll be using IIS 6 instead. IIS 6 features a revamped request processing architecture, and a slightly tweaked user interface. You’ll be able to use most of the instructions in this chapter with IIS 6, but you may want to supplement your knowledge with the online help for IIS 6 or a dedicated book about IIS 6 administration.
Creating a Virtual Directory
When you’re ready to create a new website, the first step you’ll usually take is to create the physical directory where the pages will be stored (for example, c:\MySite). The second step is to expose this physical directory as a virtual directory through IIS. This means that the website becomes publicly visible to other computers that are connected to your computer. Ordinarily, a remote computer won’t be allowed to access your c:\MySite directory. However, if you map c:\MySite to a virtual directory, the remote user will be able to request the files in the directory through IIS.
To create a new virtual directory for an existing physical directory, right-click the Default Website item in the IIS tree, and choose New -> Virtual Directory from the context menu. A wizard will start to manage the process, as shown in Figure 2-6.

Figure 2-6. The Virtual Directory Creation wizard
As you step through the wizard, you’ll need to provide three pieces of information: an alias, a directory, and a set of permissions. These settings are described in the following sections.
Alias
The alias is the name a remote client will use to access the files in this virtual directory. For example, if your alias is MyApp and your computer is named MyServer, you can request pages using URLs such as http://MyServer/MyApp/MyPage.aspx.
Directory
The directory is the physical directory on your hard drive that will be exposed as a virtual directory. For example, c:\Intetpub\wwwroot is the physical directory that is used for the root virtual directory of your web server. IIS will provide access to all the allowed file types in this directory.
Permissions
Finally, the wizard asks you to set permissions for your virtual directory, as shown in Figure 2-7. There are several permissions you can set:
To host an ASP.NET application, you only need to enable the read and execute permissions (the first two check boxes). If you’re using a development computer that will never act as a live web server, you can allow additional permissions. (Keep in mind, however, this could allow other users on a local network to access and modify files in the virtual directory.) You can also change the virtual directory permissions after you have created the virtual directory.
NOTE Remember, virtual directory permissions are only used when you’re requesting a page through IIS. If you can directly access the computer’s hard drive using Windows Explorer or some other tool, these permissions won’t come into effect.
Next: Virtual Directories and Web Applications >>
More ASP.NET Articles
More By Apress Publishing
|
This article is excerpted from chapter two of the book The Definitive Guide to SAMBA 3, written by Roderick Smith (Apress, 2004; ISBN: 1590592778). Check it out at your favorite bookstore today. Buy this book now.
|
|