Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8726551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:16:09+00:00 2026-06-13T08:16:09+00:00

I have an IIS7 web server that runs loads of sites each with multiple

  • 0

I have an IIS7 web server that runs loads of sites each with multiple bindings. Each site uses host headers AND their own IP.

Using C# I need to change the IP on all bindings to 0.0.0.0 so they listen on all the IPs.

My current code doesn’t add the new bindings but clears the old ones. Any ides what I’m doing wrong?

My Code:

using (ServerManager iisServerManager = new ServerManager())
        {
            foreach (Site site in iisServerManager.Sites)
            {
                List<Microsoft.Web.Administration.Binding> bindings = new List<Microsoft.Web.Administration.Binding>();

                foreach (Microsoft.Web.Administration.Binding binding in site.Bindings)
                {
                    String protocol = binding.Protocol;

                    String hostHeader = binding.Host;

                    String ipAddress = "0.0.0.0";

                    Int32 port = binding.EndPoint.Port;

                    String bind = ipAddress + ":" + port + ":" + hostHeader;

                    binding.BindingInformation = bind;

                    bindings.Add(binding);
                }

                //Clear existing site bindings
                site.Bindings.Clear();

                Int32 bindingCount = site.Bindings.Count();

                foreach (Microsoft.Web.Administration.Binding binding in bindings)
                {
                    site.Bindings.Add(binding);

                    bindingCount = site.Bindings.Count();
                }

                bindingCount = site.Bindings.Count();

                iisServerManager.CommitChanges();
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:16:10+00:00Added an answer on June 13, 2026 at 8:16 am

    You don’t need to remove and then re-add the same bindings. You can just modify them in place and then commit your changes. Also, you want to use the ip address of ‘*’ instead of ‘0.0.0.0’ when you want to listen on all ip addresses.

    This worked for me…

    using (ServerManager iisServerManager = new ServerManager())
    {
        foreach (Site site in iisServerManager.Sites)
        {
            foreach (Binding binding in site.Bindings)
            {
                string ipAddress = "*";
                int port = binding.EndPoint.Port;
                string hostHeader = binding.Host;
    
                binding.BindingInformation = string.Format("{0}:{1}:{2}", ipAddress, port, hostHeader);
            }
    
            iisServerManager.CommitChanges();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server that host a variety of asp.net sites on a IIS7
I have a have Winforms client that uses Web services on a IIS7 (W2008)
I have an IIS7.5 web-site, on Windows Server 2008, with an ASP.NET MVC2 web-site
We have a asp.net 2.0 web application that is running on IIS7. It is
I have a legacy web-site that I am maintaining (built mostly in classic ASP
We have recently moved to a new web server (from IIS6 to IIS7.5) and
Say that I have a bunch of PDF documents on my web server uploaded
We have recently upgraded to IIS7 as a core web server and I need
I have a file (called 'log.html') on my iis7.5 server that I would like
I have a C# Web app that runs perfectly fine in VS2010, but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.