Skip to content

Instantly share code, notes, and snippets.

Avatar
😃
Working as .Net full stack developer

Jignesh Darji Jignesh-Darji

😃
Working as .Net full stack developer
View GitHub Profile
@Jignesh-Darji
Jignesh-Darji / ChangeIISSiteBinding.cs
Last active Mar 28, 2018 — forked from vnisor/gist:42ebcc196ab2d8675df46adfc191242c
How to change bindings on a site in IIS using C#
View ChangeIISSiteBinding.cs
void ChangeSiteBinding(string siteName, string newBindingValue, string protocol)
{
using (ServerManager manager = new ServerManager())
{
// Find the site by name from IIS
Microsoft.Web.Administration.Site site = manager.Sites.Where(q => q.Name == siteName).FirstOrDefault();
if (site == null)
{
throw new Exception("The specified site name does not exist in IIS!");
}