第一步:引用 导入 System.EnterpriseServices及System.DirectoryServices 两个引用 程序引用: using System.DirectoryServices; using System.EnterpriseServices; 第二步: /// siteId  是网站的编号,ip 指向的ip 一般默认  port 一般默认80 ,domain 自定义前缀 public static void AddHostHeader(int siteid,stri…
对WebApi进行单元测试时,一般需要一个IIS站点,一般的做法,是通过写一个批处理的bat脚本来实现,其实通过编码,也能实现该功能. 主要有关注三点:应用程序池.Web站点.绑定(协议类型:http.https,IP地址,端口,主机名) 1.总体代码 var webSite = app.WebSite; using (var sm = new ServerManager()) { //创建应用程序池 var appPool = sm.ApplicationPools.FirstOrDefaul…
准备工作: 1.引用 System.DirectoryServices 系统程序集 2.引用 Microsoft.Web.Administration 程序集,类库位置在 C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll ,直接拷贝到项目引用即可 3.调用方式: string bing = string.Format("{0}:{1}:{2}", item.BingIp, item.Port, item.BingA…
//停止IIS服务 ServiceController sc = new ServiceController("iisadmin"); if(sc.Status=ServiceControllerStatus.Running) sc.Stop(); //重启IIS服务 ServiceController sc = new ServiceController("iisadmin"); sc.Start(); //重启进程 using System.Diagnostic…
这里解释两种绑定 一.全局ip未分配 二.绑定指定域名 1.添加主机名 注释:没有绑定主机名的进站默认就会被访问.绑定主机名的进站访问特定主机名的网站.…
coding:静态的在域名服务器与是填写pages.coding.me,不是填写{你的名字}.coding.me A型的ip是ping 该域名ip github:上传大项目可能报错(报错名字忘记了),原因是被墙了,隔一段时间再上传 域名设置两个A的ip 192.30.252.153 和 192.30.252.154 如果想得到的域名是有www的,CNAME文件里里填写www.你的域名 域名商那边www canme记录为{你的域名}.github.io A记录ip为{你的域名}.github.io…
停止IIS服务ServiceController sc = new ServiceController("iisadmin");if(sc.Status==ServiceControllerStatus.Running) { sc.Stop();} 重启IIS服务ServiceController sc = new ServiceController("iisadmin"); sc.Start(); 重启进程using System.Diagnostics;Proc…
虚拟主机中CP控制台不支持将二级域名绑定到子目录的功能,用户可以通过程序实现将二级域名绑定到子目录. 有两种方法将二级域名绑定到子目录: 1. 配置.htaccess, 通过伪静态代码实现.具体实现方法参考:http://help.aliyun.com/knowledge_detail/6554929.html?spm=5176.7114037.1996646101.1.SkYPg8&pos=1 虚拟主机和轻云主机通过伪静态实现子目录绑定功能 万网虚拟主机.轻云主机均不支持通过控制台cp.hic…
C#解决IIS域名批量绑定: https://shiyousan.com/post/636022975388168065 C#程序控制IIS 添加站点域名绑定: https://blog.csdn.net/hejisan/article/details/71156796…
问题现象 IIS 7.5在绑定中文域名转码后,启动站点会出现[值不在预期的范围内]: 解决方案 此问题是由于中文域名绑定错误导致的,IIS 7.5针对中文域名会自动转换为punycode码,所以不需要绑定punycode码,如果要绑定中文域名直接绑定就可以了.(简单地讲就是直接在iis管理器绑定里面删除中文域名的转码保留中文即可) -----------------------------------------------------------------------------------…