Update IIS WebsiteC#

Posted by Mdjack under C# on 4/2/2015 | Points: 10 | Views : 316 | Status : [Member] | Replies : 2
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.



Posted by: Rajnilari2015 on: 4/3/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

These are individual tasks. You can accomplish this by using Windows Workflow by performing sequential task. In one of my earlier project , we were performing almost a similar kind of task. The tool name was Build Tool.

On the other hand , you can equally write a Windows Service that will take care of all these steps and will run at the background. You may need to configure the time in the app.config . Hope this may help you.

Thanks & Regards,
RNA Team

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mdjack on: 4/4/2015 [Member] Starter | Points: 25

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.ApplicationDefaults.ApplicationPoolName = appPool.Name;

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

return true;

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


Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response