0

I am using the System.Web.Administration assembly.

Using this I am able to create websites with applications and virtual directories. And the applications are able to have virtual directories.

But there doesn't seem to be an exposed way to create an application inside of an existing application.

A Site has an ApplicationCollection called Applications, but an Application does not (it only has a VirtualDirectoryCollection.

This seems odd to me, as it is indeed possible to create applications inside applications, at least in IIS 8.

For instance, say I wish to produce the following in IIS:

-> Sites
   -> mycompany.com
      -> MyApplication
         -> SubApplication
         -> SubApplication2
         -> VirtualDirectory1

Graphically speaking:

enter image description here

Is there a way of doing this using the System.Web.Administration framework, or do I have to go down some other deep, dark path?

1 Answer 1

1

All Application are associated to a Site by its path. You can use the / separator to create Application inside other Application.

ie:

ServerManager serverManager = new ServerManager();

Site site = serverManager.Sites.Add("company.com", @"C:\tmp\company.com\www", 8080);
site.Applications.Add("/app", @"C:\tmp\company.com\app");
site.Applications.Add("/app/subApp1", @"C:\tmp\company.com\subApp1");

serverManager.CommitChanges();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It seems like the API should be able to handle this though (by automatically picking up on the parent application's path). It would make it a lot simpler.

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.