Setting Up Internet Information Services and ASP.NET - Virtual Directories and Web Applications
(Page 3 of 5 )
You can manage all the virtual directories on your computer in the Internet Information Service utility by expanding the tree under the Default Website item. You’ll notice that items in the tree have three different types of icons, as shown in Figure 2-8.

Figure 2-8. Web folders
Different icons have different meanings:
Ordinary folder. This represents a subdirectory inside another virtual directory. For example, if you create a virtual directory and then add a subdirectory to the physical directory, it will be displayed here.
Folders with a globe. This represents a virtual directory.
Package folders. This represents a virtual directory that is also a web application. By default, when you use the wizard to create a virtual directory, it’s also configured as a web application. This means that it will share a common set of resources and run in its own separate application domain. The topic of web applications is examined in more detail in Chapter 5.
When you create a virtual directory with the Virtual Directory Creation wizard, it’s also configured as a web application. This is almost always what you want. If your virtual directory isn’t a web application, you won’t be able to control its ASP.NET configuration settings, and you won’t be able to create a web application in it using Visual Studio .NET.
...........................................................................................................................
Virtual Directories Allow Access to Subdirectories
Imagine you create a virtual directory called MyApp on a computer called MyServer. The virtual directory corresponds to the physical directory c:\MyApp. If you add the subdirectory c:\MyApp\MoreFiles, this directory will automatically be included in the IIS tree as an ordinary folder. Clients will be able to access files in this folder by specifying the folder name, as in http://MyServer/MyApp/MoreFiles/SomeFile.html.
By default, the subdirectory will inherit all the permissions of the virtual directory. However, you can change these settings using the Internet Information Services utility. This is a common technique used to break a single application into different parts (for example, if some pages require heightened security settings).
...............................................................................................................................
Folder Settings IIS makes it easy to configure virtual directories after you’ve created them. Simply right-click the virtual directory in the list and choose Properties. The Properties window will appear, as shown in Figure 2-9, with its information divided into several tabs.

Figure 2-9. Web directory properties
The Virtual Directory tab contains the most important settings. These include options that allow you to change the permissions you set when creating the virtual directory with the wizard. You can also see the local path that corresponds to this virtual directory. If you’re looking at the root of a virtual directory, you can set the local path to point to a different physical directory by clicking the Browse button. If you’re looking at an ordinary subdirectory inside a virtual directory, the local path will be read-only.
Remember, when you create a virtual directory with the wizard, it’s also configured as a web application. You can change this by clicking the Remove button next to the application name. Similarly, you can click the Create button to transform an ordinary virtual directory into a full-fledged application. Usually you won’t need to perform these tasks, but it’s nice to know they are available if you need to make a change. They can come in useful when transplanting an application from one computer to another (as discussed in Chapter 12).
Any changes that you make will be automatically applied to all subdirectories. If you want to make a change that will affect all the virtual directories on your server, right-click the Default Website item and choose Properties. The change will be cascaded down to all the contained virtual directories. If your change conflicts with the custom settings that you have set for a virtual directory, IIS will warn you. It will present a list of the directories that will be affected and give you the chance to specify exactly which ones you want to change and which ones you want to leave as is (as shown in Figure 2-10).

Figure 2-10. A change that affects several directories
If you explore the directory properties, you’ll discover several other settings that affect ASP applications but don’t have any effect on ASP.NET websites. These include the Application Protection (memory isolation) setting, and the options for session state, script timeout, and default language. These settings are all replaced by ASP.NET’s new configuration file system, which you’ll learn about in Chapter 5. Some other settings are designed for security, and these are examined in Chapter 25.
TIP Remember, IIS permissions are set on a directory-by-directory basis, which means that all the files in a directory need to share the same set of IIS permissions. As a consequence, the easiest way to apply different settings to different files is to create a virtual directory with more than one subdirectory, and set different options for each subdirectory.
The next two sections briefly explain two other types of IIS configuration: custom error pages and file mappings.
Documents
This tab allows you to specify the default documents for a virtual directory. For example, consider the virtual directory http://localhost/MySite. A user can request a specific page in this directory using a URL like http://localhost/MySite/MyPage1.aspx. But what happens if the user simply types http://localhost/MySite into a web browser?
In this case, IIS will examine the list of default documents defined for that virtual directory. It will scan the list from top to bottom, and return the first matching page. Using the list in Figure 2-11, IIS will check first for a Default.htm file, then for Default.asp, index.htm, iisstart.asp, and Default.aspx. If none of these pages are found, IIS will return the HTTP 404 (page not found) error.

Figure 2-11. The default document list
You can configure the default document list by removing entries or adding new ones. Most ASP.NET applications simply use Default.aspx as their homepage.
Next: Custom Errors >>
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.
|
|