I am trying to create a Virtual Directory progeammatically using the below code:
ServerManager iisManager = new ServerManager();
iisManager.Sites.Add("NewSite", "http", "*:8080:", @"D:\mine\TestApps\TestAppXML");
iisManager.CommitChanges();
this code is working fine when using through Console application. but when I am using the same code through Web Application, it is not doing the desired job. Nor does it give any error. Anyone has ideas about why the same code is not working with Web Application?
I dont see were you are grabing the website id.
The way to do this is to manipulate the
Site.Applications
collection which is a flattened tree of all the applications in your site.If you would like to create a virtual directory try this:
If you would like to create a virtual Application use this code:
There is a great write up here