title: separate IIS binding for application
body: <p>I am trying to deploy a website by using program IN IIS 7 using c#.</p>
  
  <p>i want to deploy the application under Default website.</p>
  
  <p>the application should have a different port number (90) that is separate from other applications under Default website or even the default port number of Default website(<strong>i.e., 8080</strong>).</p>
  
  <p>I am trying to do this pro grammatically using <strong>ServerManager</strong> class without specifying any binding information in the <strong>web.config</strong> file of website.</p>
  
  <pre><code>static void CreateSite()
      {
          using (ServerManager server = new ServerManager())
          {
              if (server.Sites != null &amp;&amp; server.Sites.Count &gt; 0)
              {
                  Site defaultsite=server.Sites.FirstOrDefault(s =&gt; s.Name == "Default Web Site");
                  if (defaultsite != null)
                  {
                      string path = @"C:\inetpub\wwwroot\MyApp\";
  
                      //specify the Binding information
                      string ip = "*";
                      string port = "90";
                      string hostName = "*";
  
  
                      string bindingInfo = string.Format(@"{0}:{1}:{2}", ip, port, hostName);
                      defaultsite.Applications.Add("/MyApp", path);
  
                   server.CommitChanges();
                  }
              }
          }
      }
  </code></pre>
  
  <p>ServerManager class allows us to create/update/delete bindings for each site rather than for each application under a site as below.</p>
  
  <pre><code>                    string ip = "*";
                      string port = "90";
                      string hostName = "*";
  
  
                      string bindingInfo = string.Format(@"{0}:{1}:{2}", ip, port, hostName);
                      BindingCollection bindingCollection = defaultsite.Bindings;
                      Binding binding = defaultsite.Bindings.CreateElement("binding");
                      binding["protocol"] = "http";
                      binding["bindingInformation"] = bindingInfo;
                      bindingCollection.Add(binding);
                      server.CommitChanges();
  </code></pre>
  
  <p>How do i specify a different port number for the application in IIS 7.0 using ServerManager class methods?</p>