6

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?

1 Answer 1

7

The answer is this one:

ServerManager iisManager = new ServerManager();
Site mySite = iisManager.Sites["nameOfYourSite"];
mySite.Applications[0].VirtualDirectories.Add("/nameVirtualDirectory","VirtualDirectoryPath");
iisManager.CommitChanges();
Sign up to request clarification or add additional context in comments.

1 Comment

Because the root of the website is the Application[0].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.