广州软件测试

简体版 繁体版

 时代测试 > 网站建设小组 > !!!三打哈 > !!!三打哈 > asp.net(C#)添加、删除主机头

asp.net(C#)添加、删除主机头

准备工作:

1、在项目中添加System.EnterpriseServices引用

2、可能提示无访问权限之类的错误,在配制文件中添加

using System.DirectoryServices;
public static void AddHostHeader(int siteid, string ip, int port, string domain)//增加主机头(站点编号.ip.端口.域名)
31         {
32             DirectoryEntry site = new DirectoryEntry("IIS://localhost/W3SVC/" + siteid);
33             PropertyValueCollection serverBindings = site.Properties["ServerBindings"];
34             string headerStr = string.Format("{0}:{1}:{2}", ip, port, domain);
35             if (!serverBindings.Contains(headerStr))
36             {
37                 serverBindings.Add(headerStr);
38             }
39             site.CommitChanges();
40         }
41 
42         public static void DeleteHostHeader(int siteid, string ip, int port, string domain)//删除主机头(站点编号.ip.端口.域名)
43         {
44             DirectoryEntry site = new DirectoryEntry("IIS://localhost/W3SVC/" + siteid);
45             PropertyValueCollection serverBindings = site.Properties["ServerBindings"];
46             string headerStr = string.Format("{0}:{1}:{2}", ip, port, domain);
47             if (serverBindings.Contains(headerStr))
48             {
49                 serverBindings.Remove (headerStr);
50             }
51             site.CommitChanges();
52         }
三打哈整理

Posted @2008-1-9 16:50:43  阅读(191)  评论(0)  
最新更新
  • 应用域[三打哈]
  • 网络负载均衡技术的实现方法[三打哈]
  • SAX解析
  • DOM的四个基本接口
  • [!!!三打哈]js操作cookies类

  • 最新评论
    昵称验证码
    <内容请勿超出2000个字,快捷键:Ctrl+Enter>
    公司名片1
    广州时代软件测试
    所属行业:互联网
    联系电话:13760727218
    传真号码:020-85520605
    地址:广州天河科韵路18号
    公司网址http://test1.anyp.com
    电子邮件wazh35@126.com
    经营范围: 广州时代软件测试工作室,是由一帮工作于不同工作岗位,拥有各种技术的精英们组成的。 在他们的成员中,有能在基于为各企业建站丰富的经验,为企业的网站做全面的网站测试,从网站建设质量、用户体验、网络营销等等方面对各公司网站进行评估。 在他们的成员中,拥有以时代潮流的技术,及工作二年的测试经验,为各企业提供资深的软件测试服务,为软件双方的验收提交质量评估报告书,帮助企业提高软件
    个人简介

    !!!三打哈
    饭都不能按时吃的人,还能做些什么事呢?
    公司 广州时代软件测试
    群组 网站建设小组
    个人首页 个人首页
    我的相册 我的相册
    给我留言 给我留言
    我的栏目
    *a
    *AA
    *!!!三打哈
    日期
    copyright xk 图片旁的留言提示