Author: DevASP
Download Source Code : 655_WindowsApplication1.zip
This article is about how you can create a virtual directory using .NET framework.
Using Internet Information Services (IIS) Manager, you can create a virtual directory for an ASP.NET Web application. A virtual directory appears to client browsers as though it were contained in a 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 on your 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 site identity, which means that it requires fewer steps than creating a unique site. This topic explains how you can create a virtual directory using VS.NET to run ASP.NET pages.
To create a virtual directory, a Web site must already be created on the Web server. IIS creates a default Web site on the computer during installation. If you have not created a site of your own, you can create a virtual directory under the default Web site.
Steps you will do.
Start visual studio and create a new widow application for vb.net
Set the following properties of the form object.
Drop two label controls on the form and set their following properties. First label control.
Second label control.
Now drop two text fields on the form and set their following properties.
First text box control
Second text box control
Drop a button control on the form and set its following properties.
Open the code window of form and import the following namespace.
Declare a function as below to create the virtual directory.
'If the virtual directory already exists then delete it
For Each VD As System.DirectoryServices.DirectoryEntry In IISAdmin.Children
Write the following code in the click event of the create button to call the above function and pass the parameters as below.
Run your application. Enter the name with which you want to create virtual directory in IIS. Enter the path where you want to create the virtual directory on hard drive and finally click the create button to create the virtual directory.