Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my local IIS there is Default Web Site inside which I have created one application /MyAppName

I need to add virtual directory to this application(/MyAppName) using asp.net c# Code

Virtual directory Name
/Name

Virtula directory path
C:/Inetpub/wwwroot

What I have tried:

Found some examples on net but dint understand how to get particular app name and add virtual directory inside that application.
Posted
Updated 22-Apr-16 1:15am
Comments
Herman<T>.Instance 22-Apr-16 4:14am    
Have you added an APP Pool? Is the correct version of .NET Framework installed in IIS? Which settings have you used when creating the APP in IIS?
Raj.Rautela 22-Apr-16 4:52am    
Apppool name is same as appname with framework ver 4.0 and mode is classic
Bernhard Hiller 22-Apr-16 6:03am    
Creating a Virtual Directory by code from a web application .... Well, I hope that's prevented by security mechanisms. Use some server management tools for that purpose.
ZurdoDev 22-Apr-16 7:16am    
It is easily doable and for good reasons. If you are a hoster and want to allow new clients to create a site so they can have their own website. But you do, of course, have to have the proper permissions and checks in place.
Bernhard Hiller 22-Apr-16 9:16am    
My 5 for your solution. Still I hope that the account IIS is running on has not sufficient rights for doing so, thus impersonation or something like that is required - "the proper permissions and checks" ...

1 solution

System.DirectoryServices is the namespace you'll need. See example on MSDN, Creating Sites and Virtual Directories Using System.DirectoryServices[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900