Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add web site under Default web site in IIS using c#. I am able to create web site outside default web site.

What I have tried:

My code is as below:
ServerManager iisManager = new ServerManager();
          iisManager.Sites.Add(WebSiteName, httpprefix, bindinginfo, PublishPath);

          //iisManager.Sites["Default Web Site"].Applications.Add("/Web", Drive + "/Portal/Web");
          iisManager.Sites[WebSiteName].ApplicationDefaults.ApplicationPoolName = AppPool;
          //Start App Pool of the Created Web Site
          var AppPoolToStart = new ServerManager().ApplicationPools[AppPool];
          if (AppPoolToStart != null)
              AppPoolToStart.Start();
          iisManager.CommitChanges();
Posted
Comments
Richard Deeming 8-Aug-19 10:21am    
You can't add a web site inside another web site. You can only add an application inside a web site.

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