- In ASP.NET virtual directory represents a web application or WebProject and it points to a physical folder in your own computer.
- A web application is accessed using a virtual directory name instead of a physical folder name. For example, if you have a web application called "Inventory" in your machine, and if you Create a virtual directory for this web application. You will access your web application using the URL httP://localhost/Inventory. If your virtaul directory name is "TestData", then your web application url will be "http://localhost/TestData".
- Assume you have a web application called "Inventory", created under the physical folder "C:\MyProjects\Inventory".
- You can go to IIS (internet Information Server) and see this virtual directory listed. Right click on this virtual directory name in IIS and see the properties. You can see that this virtual directory is pointing to the physical location "C:\MyProjects\Inventory".
- If you have a file called ""File1.aspx" under the folder "C:\MyProjects\Inventory\", then you can access this file using Internet Explorer with the URL "http://localhost/Inventory/File1.aspx".
When you create a new web project using, a new virtual directory will be created automatically for you. This virtual directory will point to a new folder created under C:\Inetpub\wwwroot.
If you like to better organize your projects and files in your favorites folder, you must manually create a new folder for each project in your preferred location and convert it into a virtual folder manually.
There are couple of ways you can do this.
Method 1: Open the IIS. Right click on the node "Default Web Site" and select "new Virtual Directory"". When it prompt you to enter the "alias", enter the virtual directory name you want(Eg: Inventory). In the prompt for "directory", select the folder which you want to make a virtual directory (Eg: C:\MyProjects\Inventory). Select other default values and press "Finish". Now you should be able to see your new virtual directory in IIS.
Method 2: In the explorer, go to the folder(Eg: C:\MyProjects\Inventory) which you want to make a "virtual directory". Right click on the folder name and select "Properties". Select the tab "Web sharing" and select teh option "Share this folder". It will prompt you with a default Alias name same as the folder name (Eg: Inventory). Simply select the default values and press "OK".