Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set IIS Host-Header programatic

Status
Not open for further replies.

rollek

Programmer
May 29, 2007
2
DE
Hi,
I want to set IIS host heades programatic (.NET-Code).

I have a Website, which enables personalized access through subdomain. I use host headers for that purpose. Because of having about 1 to 5 host header changes each day, I decided to write a tool (ASP.NET Website) for administration.

Now my question: Is it possible to administrate IIS through .NET-Code? Is there a library that support access to the IIS administration ... maybe that way:

IISWrapper iis = new IISWrapper();
iis.AddHostHeader( string websiteID, string hostheaderWert, int port );

or

iis.DeleteHostHeader( string websiteID, string hostheaderWert, int port );

Thanks in advance

Regards rollek
 
Hi All, i have it.

-------------------------------------------
object[] serverBindings = new object[1];

// ":[port]:[hostheader]
serverBindings[0] = ":80:domain.de";

// "IIS://[server]/W3SVC/[websiteID]"
System.DirectoryServices.DirectoryEntry website = new System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1");
website.Properties["ServerBindings"].Value = serverBindings;

website.CommitChanges();
website.Dispose();
-------------------------------------------

Regards Rollek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top