C# - Append a host header by code in IIS

the following example adds a host header to a website in IIS. This involves changing the ServerBindings property. There is no Append method that can be used to append a new serverbinding to this property, so what needs to be done is read the entire property and then add it back again, together with the new data. This is what is done in the code below. The ServerBindings property's data type is MULTISZ, and the string format is IP:Port:Hostname. 
Note that this example code does not do any error checking. It is important that every ServerBindings entry is unique, and you - the programmer - is responsible for checking this (which means that you need to loop thru all entries and check if what is about to be added is unique).

Code




 感谢原创者的辛勤劳动,希望对您有所帮助,转载请注明原出处。
 您可能对 [C#] 的这些文章也感兴趣:

在C# 中实现 Singleton
C#积木模块ABC(四)
匹配Unicode字符的正则表达式
如何把图片插入Excel的一个单元格中
全面剖析VB.NET(6)
C#数字图像探索系列(1)--伪渐变效果原理及应用初级篇
C# 4.0新特性(中英文对照白皮书)
c#摄像头编程
针对C#的CodeRush Xpress免费发布
微软开放Tafiti可视化搜索源代码