Tutorials » AspNet tutorials »

Working with IIS and virtual directories

This article explains how to use IIS and how to work with virtual directories.

Internet Information Services (IIS) helps you manage the web applications and web sites in your computer.

How to open IIS

There are several ways you can open the Internet Information Services tool.

Method 1: Open the 'Control Panel', select 'Administrative Tools' and then double click the shortcut 'Internet Information Services'

Method 2: Go to the "start" menu, select "Run" and then type "inetmgr". Press "OK" to open the IIS tool.

The IIS admin tool look like this:

In the above image, the name "MANJU" represents the computer name. Under the node "Web Sites", it displays all the web sites. When you install IIS, it creates a default web site for you. Under the "Default Web Site" node, you can see all virtual directories listed.

Only on server operating systems like 'Windows 2000 Server' or 'Windows 2003 Server', you can create multiple Web Sites. In other systems like Windows XP, Windows 2000 Professional etc, you can have only 1 web site (which is the 'Default Web Site' created by the system). But you can have any number of web applications under this default web site. Each web application will need to be created as a 'virtual directory' under any one of the 'web sites'. If you do not have a server operating system, you have to always create your web applications under the 'Default Web Site'.

Each web application you create in your machine needs a virtual directory. In the above image, we have two web applications (named 'WebApplication1' and 'WebApplication2')

When you create a new ASP.NET project using Visual Studio .NET, it will automatically create a virtual directory for you.

For example, if you create a new ASP.NET project using Visual Studio .NET called "ShoppingCart", it will create a new virtual directory with the name "ShoppingCart". After you create the ASP.NET project, you can see the virtual directory listed in the IIS.

You can right click on the virtual directory name in IIS and select 'Properties' to view various properties of the virtual directory. One important property is "Local Path". The "Local Path" property represents the actual location of the web application.

By default, when you create a new ASP.NET project, visual studio creates the project under the folder "C:\Inetpub\WWWRoot". For example, if you create a new ASP.NET project called "ShopCart", VS.NET creates a folder called "C:\Inetpub\WWWRoot\ShopCart" and all files related to the proejct will be placed inside this folder. This folder will be set as a "Virtual Folder" so that you can access the web site using the URL "http://localhost/ShopCart".

If you are working on several projects, you may want to organize your projects in some specific folder instead of "C:\Inetpub\WWWRoot". What you need to do is, create a virtual folder manually before you create the project.

For example, if you need to create an ASP.NET applciation called "Shopcart" under the folder "C:\MyProjects", first create the folder "C:\MyProjects\Shopcart". Now convert this folder as a virtual folder. Now you are ready to create the project using VS.NET. If the virtual folder already exists, VS.NET will NOT create a new virtual folder under the WWWRoot folder. It will use the existing virtual folder.

What is "localhost" ?

"localhost" represents "current machine". If you are accessing any web applications in your own machine, you can use the url http://localhost/XXXXXXX. If your web site is in another machine, you can use the IP Address of the computer instead of "localhost". For example, if the "Shopcart" web application is in a computer with the IP Address "", then you can access the site from your comptuer using the url "".

Stop and start IIS

You may never need to stop and start your IIS. When your computer is started, IIS is automtically started.

Actually, IIS is a 'windows service'. What you see as 'Internet Information Services' is an admin tool provided by Microsoft to manage the real IIS which works in the background. IIS runs as a windows service in the background and what you see is only a tool to manage the IIS service.

If you like to stop or start IIS, select the "Default Web Site" in IIS tool and select "stop" or "start" from the right click menu. If you stop IIS, you cannot access your web sites anymore. Even, if you try to open the ASP.NET project in Visual Studio, it will complain that web site is currently not available.

Next Chapter: What is a Virtual Directory and how to create it?
Previous Chapter: Installing and configuring IIS
More Chapters: ASP.NET Tutorials
More Tutorials: Tutorial Index

Top Contributors
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India