Skip to content

Update IIS Website settings Programmatically

MOHAMED JACKARIAH

Asked Apr 2, 2015, 7:51 AM EDT2 answers
Share
LinkedInX
Programmatically I created the Website in IIS using the C# programming.
I want to update the created site following information
1. Replace the published files in Virtual directory.
2. IP Address.
3. Port Number.
4. AppPool Name.
5. AppPool Identity User Name.
6. AppPool Identity Password.
7. Runtime Version.
8. ManagedPipline Mode.
Please Help on this its very urgent task for me to complete.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Vithal Wadje
    +1
    Need to think on it ,its require time
    +1
  • +1
    I am getting the above mentioned updated information from user and i validate those information successfully. Also i created the method and pass all information to the function.

    Using the selected SiteName I am getting the site information from ServerManager. Here I am getting confusion how to update selected site information and settings.


    public static bool UpdateWebSiteInfo(string siteName, int port, string RootPath, string AppPool, string FWVersion, string Pipe, string Binding, string SvrUsrId, string SvrPwd)
    {
    using (ServerManager sManager=new ServerManager())
    {
    // get site by Index or by siteName
    Site ss = sManager.Sites[siteName];
    // get appPool by Index or by appPoolName
    ApplicationPool appPool = sManager.ApplicationPools[AppPool];

    ss.Stop();
    ss.ApplicationDefaults.ApplicationPoolName = appPool.Name;

    foreach (var item in ss.Applications)
    {
    item.ApplicationPoolName = appPool.Name;

    }
    sManager.CommitChanges();
    ss.Start();
    appPool.Recycle();
    }
    return true;
    }


    I tried with above function getting the Object set to Instance exception.
    +1