Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Programmatically I created the Website in IIS using the C# programming.
I want to update the created site following information

1. Replace Virtual directory files.
2. IP Address.
3. Port Number.
4. AppPool Name.
5. AppPool Identity User Name.
6. AppPool Identity Password.
7. Runtime Version.
8. ManagedPipline Mode.
Posted
Updated 2-Apr-15 6:14am
v2
Comments
Sergey Alexandrovich Kryukov 2-Apr-15 11:57am    
IP?! He-he...
—SA
ZurdoDev 2-Apr-15 12:35pm    
Where are you stuck?
Mohamed Zackkariah 2-Apr-15 22:54pm    
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.

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