I am going to adding bindings in IIS 7 using below code and it is working fine with visual studio and IIS Express.
But when I host same project in IIS 7 then it is redirecting me on login page even I am already login, and bindings also not adding.
using (ServerManager manager = new ServerManager())
// Find the site by name from IIS
Microsoft.Web.Administration.Site site = manager.Sites.Where(q => q.Name == "test").FirstOrDefault();
site.Bindings.Add("*:81:" + "google1.com", "http");
// Set auto start to true.
site.ServerAutoStart = true;
// Commit the changes