Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am creating site programmatically in c# using Microsoft.Web.Administration as below.



and if the site exists in IIS, I am trying to change the bindings as below.

C#
 Microsoft.Web.Administration.ServerManager mgr = new Microsoft.Web.Administration.ServerManager();
                Microsoft.Web.Administration.Site site = null;
if (!DoesWebSiteExist(SITE))
               {

                   if (!System.IO.Directory.Exists(physicalPath))
                   {
                       System.IO.Directory.CreateDirectory(physicalPath);
                   }
                   site = mgr.Sites.Add(SITE, physicalPath, System.Convert.ToInt32(ASPORT));
                   site.ApplicationDefaults.ApplicationPoolName = POOL;
                   site.Bindings.Clear();
                   site.Bindings.Add(bindinfo, "http");
                   site.ServerAutoStart = true;
                   mgr.CommitChanges();
               }
               else
               {
                   site = mgr.Sites[SITE];
                   site.ServerAutoStart = true;
                   site.Bindings.Clear();
                   site.Bindings.Add(bindinfo, "http");
                   site.ServerAutoStart = true;
                   mgr.CommitChanges();
               }


I want to change the physical path of the site if the site already exists. How can i do that ? Help much appreciated.

Thanks
PMM
Posted
Updated 6-Jun-12 20:18pm
v2

1 solution

I found it.

C#
site.Applications["/"].VirtualDirectories["/"].PhysicalPath = physicalPath;


Thanks
PMM
 
Share this answer
 

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