Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create IIS7 virtual directory programmatically

I can create Virtual directories in an application with this code:

ServerManager iisManager = new ServerManager();
Application app = iisManager.Sites["NewSite"].Applications["/Sales"];
app.VirtualDirectories.Add("/VDir", "d:\\MyVDir");
iisManager.CommitChanges();

But I cannot create a Virtual directory in the root of the Website.

¿Any ideas?

like image 236
Za7pi Avatar asked May 30 '14 10:05

Za7pi


1 Answers

The answer is this one:

ServerManager iisManager = new ServerManager();
Site mySite = iisManager.Sites["nameOfYourSite"];
mySite.Applications[0].VirtualDirectories.Add("/nameVirtualDirectory","VirtualDirectoryPath");
iisManager.CommitChanges();
like image 94
Za7pi Avatar answered Sep 23 '22 01:09

Za7pi