利用IIS7自带类库管理IIS现在变的更强大更方便,而完全可以不需要用DirecotryEntry这个类了(网上很多.net管理iis6.0的文章都用到了DirecotryEntry这个类 ),Microsoft.Web.Administration.dll位于IIS的目录(%WinDir%\\System32\\InetSrv)下,使用时需要引用,它基本上可以管理IIS7的各项配置。

这个类库的主体结构如下:

主要调用code 如下:

  using (ServerManager sm = ServerManager.OpenRemote("192.168.0.129"))
{
//创建站点
sm.Sites.Add("test", @"D:\DataBackup", 9898);
//创建应用程序池
sm.ApplicationPools.Add("test");
//设置站点的应用程序池
sm.Sites["test"].Applications[0].ApplicationPoolName = "test";
sm.CommitChanges();
}
  void CreateIISSite(string serverIP, string webName, int port, string path)
{
try
{
using (ServerManager sm = ServerManager.OpenRemote(serverIP))
{
//创建应用程序池
ApplicationPool appPool = sm.ApplicationPools.FirstOrDefault(x => x.Name == webName);
if (appPool == null)
{
appPool = sm.ApplicationPools.Add(webName);
appPool.AutoStart = false; appPool.QueueLength = 10000;
appPool.StartMode = StartMode.AlwaysRunning;//启动模式
appPool.Recycling.PeriodicRestart.Time = new TimeSpan();//回收时间间隔
appPool.ProcessModel.IdleTimeout = new TimeSpan();//闲置超时
appPool.ProcessModel.MaxProcesses = 1;//最大工作进程数
}
//创建Site
Site site = sm.Sites.FirstOrDefault(x => x.Name == webName);
if (site == null)
{
site = sm.Sites.Add(webName, path, port);
site.ServerAutoStart = true; site.Bindings[0].EndPoint.Port = port;
Application root = site.Applications["/"];
root.ApplicationPoolName = webName;
root.VirtualDirectories["/"].PhysicalPath = path;
root.SetAttributeValue("preloadEnabled", true); /*预加载*/
}
sm.CommitChanges();
} }
catch (Exception ex)
{
ExceptionUtil.Throw(ex);
} }

检查 计算机 是否安装有IIS   var service = ServiceController.GetServices(serverIp).FirstOrDefault(x => x.ServiceName == "W3SVC");

有关IIS预加载 大家可以参考:预加载会执行Application_Start方法。

IIS初始化(预加载),解决第一次访问慢,程序池被回收问题
IIS预编译提升加载速度

后来在网上发下一个查询属性的code 不错,先copy过来

 
 Microsoft.Web.Administration.ServerManager sm = new Microsoft.Web.Administration.ServerManager();

            System.Console.WriteLine("应用程序池默认设置:");
System.Console.WriteLine("\t常规:");
System.Console.WriteLine("\t\t.NET Framework 版本:{0}", sm.ApplicationPoolDefaults.ManagedRuntimeVersion);
System.Console.WriteLine("\t\t队列长度:{0}", sm.ApplicationPoolDefaults.QueueLength);
System.Console.WriteLine("\t\t托管管道模式:{0}", sm.ApplicationPoolDefaults.ManagedPipelineMode.ToString());
System.Console.WriteLine("\t\t自动启动:{0}", sm.ApplicationPoolDefaults.AutoStart); System.Console.WriteLine("\tCPU:");
System.Console.WriteLine("\t\t处理器关联掩码:{0}", sm.ApplicationPoolDefaults.Cpu.SmpProcessorAffinityMask);
System.Console.WriteLine("\t\t限制:{0}", sm.ApplicationPoolDefaults.Cpu.Limit);
System.Console.WriteLine("\t\t限制操作:{0}", sm.ApplicationPoolDefaults.Cpu.Action.ToString());
System.Console.WriteLine("\t\t限制间隔(分钟):{0}", sm.ApplicationPoolDefaults.Cpu.ResetInterval.TotalMinutes);
System.Console.WriteLine("\t\t已启用处理器关联:{0}", sm.ApplicationPoolDefaults.Cpu.SmpAffinitized); System.Console.WriteLine("\t回收:");
System.Console.WriteLine("\t\t发生配置更改时禁止回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowRotationOnConfigChange);
System.Console.WriteLine("\t\t固定时间间隔(分钟):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Time.TotalMinutes);
System.Console.WriteLine("\t\t禁用重叠回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowOverlappingRotation);
System.Console.WriteLine("\t\t请求限制:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Requests);
System.Console.WriteLine("\t\t虚拟内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Memory);
System.Console.WriteLine("\t\t专用内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.PrivateMemory);
System.Console.WriteLine("\t\t特定时间:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Schedule.ToString());
System.Console.WriteLine("\t\t生成回收事件日志条目:{0}", sm.ApplicationPoolDefaults.Recycling.LogEventOnRecycle.ToString()); System.Console.WriteLine("\t进程孤立:");
System.Console.WriteLine("\t\t可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionExe);
System.Console.WriteLine("\t\t可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionParams);
System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.OrphanWorkerProcess); System.Console.WriteLine("\t进程模型:");
System.Console.WriteLine("\t\tPing 间隔(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingInterval.TotalSeconds);
System.Console.WriteLine("\t\tPing 最大响应时间(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingResponseTime.TotalSeconds);
System.Console.WriteLine("\t\t标识:{0}", sm.ApplicationPoolDefaults.ProcessModel.IdentityType);
System.Console.WriteLine("\t\t用户名:{0}", sm.ApplicationPoolDefaults.ProcessModel.UserName);
System.Console.WriteLine("\t\t密码:{0}", sm.ApplicationPoolDefaults.ProcessModel.Password);
System.Console.WriteLine("\t\t关闭时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.ShutdownTimeLimit.TotalSeconds);
System.Console.WriteLine("\t\t加载用户配置文件:{0}", sm.ApplicationPoolDefaults.ProcessModel.LoadUserProfile);
System.Console.WriteLine("\t\t启动时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.StartupTimeLimit.TotalSeconds);
System.Console.WriteLine("\t\t允许 Ping:{0}", sm.ApplicationPoolDefaults.ProcessModel.PingingEnabled);
System.Console.WriteLine("\t\t闲置超时(分钟):{0}", sm.ApplicationPoolDefaults.ProcessModel.IdleTimeout.TotalMinutes);
System.Console.WriteLine("\t\t最大工作进程数:{0}", sm.ApplicationPoolDefaults.ProcessModel.MaxProcesses); System.Console.WriteLine("\t快速故障防护:");
System.Console.WriteLine("\t\t“服务不可用”响应类型:{0}", sm.ApplicationPoolDefaults.Failure.LoadBalancerCapabilities.ToString());
System.Console.WriteLine("\t\t故障间隔(分钟):{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionInterval.TotalMinutes);
System.Console.WriteLine("\t\t关闭可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownExe);
System.Console.WriteLine("\t\t关闭可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownParams);
System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtection);
System.Console.WriteLine("\t\t最大故障数:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionMaxCrashes);
System.Console.WriteLine("\t\t允许32位应用程序运行在64位 Windows 上:{0}", sm.ApplicationPoolDefaults.Enable32BitAppOnWin64); System.Console.WriteLine();
System.Console.WriteLine("网站默认设置:");
System.Console.WriteLine("\t常规:");
System.Console.WriteLine("\t\t物理路径凭据:UserName={0}, Password={1}", sm.VirtualDirectoryDefaults.UserName, sm.VirtualDirectoryDefaults.Password);
System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", sm.VirtualDirectoryDefaults.LogonMethod.ToString());
System.Console.WriteLine("\t\t应用程序池:{0}", sm.ApplicationDefaults.ApplicationPoolName);
System.Console.WriteLine("\t\t自动启动:{0}", sm.SiteDefaults.ServerAutoStart);
System.Console.WriteLine("\t行为:");
System.Console.WriteLine("\t\t连接限制:");
System.Console.WriteLine("\t\t\t连接超时(秒):{0}", sm.SiteDefaults.Limits.ConnectionTimeout.TotalSeconds);
System.Console.WriteLine("\t\t\t最大并发连接数:{0}", sm.SiteDefaults.Limits.MaxConnections);
System.Console.WriteLine("\t\t\t最大带宽(字节/秒):{0}", sm.SiteDefaults.Limits.MaxBandwidth);
System.Console.WriteLine("\t\t失败请求跟踪:");
System.Console.WriteLine("\t\t\t跟踪文件的最大数量:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.MaxLogFiles);
System.Console.WriteLine("\t\t\t目录:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Directory);
System.Console.WriteLine("\t\t\t已启用:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Enabled);
System.Console.WriteLine("\t\t已启用的协议:{0}", sm.ApplicationDefaults.EnabledProtocols); foreach (var s in sm.Sites)//遍历网站
{
System.Console.WriteLine();
System.Console.WriteLine("模式名:{0}", s.Schema.Name);
System.Console.WriteLine("编号:{0}", s.Id);
System.Console.WriteLine("网站名称:{0}", s.Name);
System.Console.WriteLine("物理路径:{0}", s.Applications["/"].VirtualDirectories["/"].PhysicalPath);
System.Console.WriteLine("物理路径凭据:{0}", s.Methods.ToString());
System.Console.WriteLine("应用程序池:{0}", s.Applications["/"].ApplicationPoolName);
System.Console.WriteLine("已启用的协议:{0}", s.Applications["/"].EnabledProtocols);
System.Console.WriteLine("自动启动:{0}", s.ServerAutoStart);
System.Console.WriteLine("运行状态:{0}", s.State.ToString()); System.Console.WriteLine("网站绑定:");
foreach (var tmp in s.Bindings)
{
System.Console.WriteLine("\t类型:{0}", tmp.Protocol);
System.Console.WriteLine("\tIP 地址:{0}", tmp.EndPoint.Address.ToString());
System.Console.WriteLine("\t端口:{0}", tmp.EndPoint.Port.ToString());
System.Console.WriteLine("\t主机名:{0}", tmp.Host);
//System.Console.WriteLine(tmp.BindingInformation);
//System.Console.WriteLine(tmp.CertificateStoreName);
//System.Console.WriteLine(tmp.IsIPPortHostBinding);
//System.Console.WriteLine(tmp.IsLocallyStored);
//System.Console.WriteLine(tmp.UseDsMapper);
} System.Console.WriteLine("连接限制:");
System.Console.WriteLine("\t连接超时(秒):{0}", s.Limits.ConnectionTimeout.TotalSeconds);
System.Console.WriteLine("\t最大并发连接数:{0}", s.Limits.MaxConnections);
System.Console.WriteLine("\t最大带宽(字节/秒):{0}", s.Limits.MaxBandwidth); System.Console.WriteLine("失败请求跟踪:");
System.Console.WriteLine("\t跟踪文件的最大数量:{0}", s.TraceFailedRequestsLogging.MaxLogFiles);
System.Console.WriteLine("\t目录:{0}", s.TraceFailedRequestsLogging.Directory);
System.Console.WriteLine("\t已启用:{0}", s.TraceFailedRequestsLogging.Enabled); System.Console.WriteLine("日志:");
//System.Console.WriteLine("\t启用日志服务:{0}", s.LogFile.Enabled);
System.Console.WriteLine("\t格式:{0}", s.LogFile.LogFormat.ToString());
System.Console.WriteLine("\t目录:{0}", s.LogFile.Directory);
System.Console.WriteLine("\t文件包含字段:{0}", s.LogFile.LogExtFileFlags.ToString());
System.Console.WriteLine("\t计划:{0}", s.LogFile.Period.ToString());
System.Console.WriteLine("\t最大文件大小(字节):{0}", s.LogFile.TruncateSize);
System.Console.WriteLine("\t使用本地时间进行文件命名和滚动更新:{0}", s.LogFile.LocalTimeRollover); System.Console.WriteLine("----应用程序的默认应用程序池:{0}", s.ApplicationDefaults.ApplicationPoolName);
System.Console.WriteLine("----应用程序的默认已启用的协议:{0}", s.ApplicationDefaults.EnabledProtocols);
//System.Console.WriteLine("----应用程序的默认物理路径凭据:{0}", s.ApplicationDefaults.Methods.ToString());
//System.Console.WriteLine("----虚拟目录的默认物理路径凭据:{0}", s.VirtualDirectoryDefaults.Methods.ToString());
System.Console.WriteLine("----虚拟目录的默认物理路径凭据登录类型:{0}", s.VirtualDirectoryDefaults.LogonMethod.ToString());
System.Console.WriteLine("----虚拟目录的默认用户名:{0}", s.VirtualDirectoryDefaults.UserName);
System.Console.WriteLine("----虚拟目录的默认用户密码:{0}", s.VirtualDirectoryDefaults.Password);
System.Console.WriteLine("应用程序 列表:");
foreach (var tmp in s.Applications)
{
if (tmp.Path != "/")
{
System.Console.WriteLine("\t模式名:{0}", tmp.Schema.Name);
System.Console.WriteLine("\t虚拟路径:{0}", tmp.Path);
System.Console.WriteLine("\t物理路径:{0}", tmp.VirtualDirectories["/"].PhysicalPath);
//System.Console.WriteLine("\t物理路径凭据:{0}", tmp.Methods.ToString());
System.Console.WriteLine("\t应用程序池:{0}", tmp.ApplicationPoolName);
System.Console.WriteLine("\t已启用的协议:{0}", tmp.EnabledProtocols);
}
System.Console.WriteLine("\t虚拟目录 列表:");
foreach (var tmp2 in tmp.VirtualDirectories)
{
if (tmp2.Path != "/")
{
System.Console.WriteLine("\t\t模式名:{0}", tmp2.Schema.Name);
System.Console.WriteLine("\t\t虚拟路径:{0}", tmp2.Path);
System.Console.WriteLine("\t\t物理路径:{0}", tmp2.PhysicalPath);
//System.Console.WriteLine("\t\t物理路径凭据:{0}", tmp2.Methods.ToString());
System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", tmp2.LogonMethod.ToString());
}
}
}
}
 Microsoft.Web.Administration.ServerManager sm = new Microsoft.Web.Administration.ServerManager();

            System.Console.WriteLine("应用程序池默认设置:");
System.Console.WriteLine("\t常规:");
System.Console.WriteLine("\t\t.NET Framework 版本:{0}", sm.ApplicationPoolDefaults.ManagedRuntimeVersion);
System.Console.WriteLine("\t\t队列长度:{0}", sm.ApplicationPoolDefaults.QueueLength);
System.Console.WriteLine("\t\t托管管道模式:{0}", sm.ApplicationPoolDefaults.ManagedPipelineMode.ToString());
System.Console.WriteLine("\t\t自动启动:{0}", sm.ApplicationPoolDefaults.AutoStart); System.Console.WriteLine("\tCPU:");
System.Console.WriteLine("\t\t处理器关联掩码:{0}", sm.ApplicationPoolDefaults.Cpu.SmpProcessorAffinityMask);
System.Console.WriteLine("\t\t限制:{0}", sm.ApplicationPoolDefaults.Cpu.Limit);
System.Console.WriteLine("\t\t限制操作:{0}", sm.ApplicationPoolDefaults.Cpu.Action.ToString());
System.Console.WriteLine("\t\t限制间隔(分钟):{0}", sm.ApplicationPoolDefaults.Cpu.ResetInterval.TotalMinutes);
System.Console.WriteLine("\t\t已启用处理器关联:{0}", sm.ApplicationPoolDefaults.Cpu.SmpAffinitized); System.Console.WriteLine("\t回收:");
System.Console.WriteLine("\t\t发生配置更改时禁止回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowRotationOnConfigChange);
System.Console.WriteLine("\t\t固定时间间隔(分钟):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Time.TotalMinutes);
System.Console.WriteLine("\t\t禁用重叠回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowOverlappingRotation);
System.Console.WriteLine("\t\t请求限制:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Requests);
System.Console.WriteLine("\t\t虚拟内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Memory);
System.Console.WriteLine("\t\t专用内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.PrivateMemory);
System.Console.WriteLine("\t\t特定时间:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Schedule.ToString());
System.Console.WriteLine("\t\t生成回收事件日志条目:{0}", sm.ApplicationPoolDefaults.Recycling.LogEventOnRecycle.ToString()); System.Console.WriteLine("\t进程孤立:");
System.Console.WriteLine("\t\t可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionExe);
System.Console.WriteLine("\t\t可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionParams);
System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.OrphanWorkerProcess); System.Console.WriteLine("\t进程模型:");
System.Console.WriteLine("\t\tPing 间隔(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingInterval.TotalSeconds);
System.Console.WriteLine("\t\tPing 最大响应时间(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingResponseTime.TotalSeconds);
System.Console.WriteLine("\t\t标识:{0}", sm.ApplicationPoolDefaults.ProcessModel.IdentityType);
System.Console.WriteLine("\t\t用户名:{0}", sm.ApplicationPoolDefaults.ProcessModel.UserName);
System.Console.WriteLine("\t\t密码:{0}", sm.ApplicationPoolDefaults.ProcessModel.Password);
System.Console.WriteLine("\t\t关闭时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.ShutdownTimeLimit.TotalSeconds);
System.Console.WriteLine("\t\t加载用户配置文件:{0}", sm.ApplicationPoolDefaults.ProcessModel.LoadUserProfile);
System.Console.WriteLine("\t\t启动时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.StartupTimeLimit.TotalSeconds);
System.Console.WriteLine("\t\t允许 Ping:{0}", sm.ApplicationPoolDefaults.ProcessModel.PingingEnabled);
System.Console.WriteLine("\t\t闲置超时(分钟):{0}", sm.ApplicationPoolDefaults.ProcessModel.IdleTimeout.TotalMinutes);
System.Console.WriteLine("\t\t最大工作进程数:{0}", sm.ApplicationPoolDefaults.ProcessModel.MaxProcesses); System.Console.WriteLine("\t快速故障防护:");
System.Console.WriteLine("\t\t“服务不可用”响应类型:{0}", sm.ApplicationPoolDefaults.Failure.LoadBalancerCapabilities.ToString());
System.Console.WriteLine("\t\t故障间隔(分钟):{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionInterval.TotalMinutes);
System.Console.WriteLine("\t\t关闭可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownExe);
System.Console.WriteLine("\t\t关闭可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownParams);
System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtection);
System.Console.WriteLine("\t\t最大故障数:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionMaxCrashes);
System.Console.WriteLine("\t\t允许32位应用程序运行在64位 Windows 上:{0}", sm.ApplicationPoolDefaults.Enable32BitAppOnWin64); System.Console.WriteLine();
System.Console.WriteLine("网站默认设置:");
System.Console.WriteLine("\t常规:");
System.Console.WriteLine("\t\t物理路径凭据:UserName={0}, Password={1}", sm.VirtualDirectoryDefaults.UserName, sm.VirtualDirectoryDefaults.Password);
System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", sm.VirtualDirectoryDefaults.LogonMethod.ToString());
System.Console.WriteLine("\t\t应用程序池:{0}", sm.ApplicationDefaults.ApplicationPoolName);
System.Console.WriteLine("\t\t自动启动:{0}", sm.SiteDefaults.ServerAutoStart);
System.Console.WriteLine("\t行为:");
System.Console.WriteLine("\t\t连接限制:");
System.Console.WriteLine("\t\t\t连接超时(秒):{0}", sm.SiteDefaults.Limits.ConnectionTimeout.TotalSeconds);
System.Console.WriteLine("\t\t\t最大并发连接数:{0}", sm.SiteDefaults.Limits.MaxConnections);
System.Console.WriteLine("\t\t\t最大带宽(字节/秒):{0}", sm.SiteDefaults.Limits.MaxBandwidth);
System.Console.WriteLine("\t\t失败请求跟踪:");
System.Console.WriteLine("\t\t\t跟踪文件的最大数量:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.MaxLogFiles);
System.Console.WriteLine("\t\t\t目录:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Directory);
System.Console.WriteLine("\t\t\t已启用:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Enabled);
System.Console.WriteLine("\t\t已启用的协议:{0}", sm.ApplicationDefaults.EnabledProtocols); foreach (var s in sm.Sites)//遍历网站
{
System.Console.WriteLine();
System.Console.WriteLine("模式名:{0}", s.Schema.Name);
System.Console.WriteLine("编号:{0}", s.Id);
System.Console.WriteLine("网站名称:{0}", s.Name);
System.Console.WriteLine("物理路径:{0}", s.Applications["/"].VirtualDirectories["/"].PhysicalPath);
System.Console.WriteLine("物理路径凭据:{0}", s.Methods.ToString());
System.Console.WriteLine("应用程序池:{0}", s.Applications["/"].ApplicationPoolName);
System.Console.WriteLine("已启用的协议:{0}", s.Applications["/"].EnabledProtocols);
System.Console.WriteLine("自动启动:{0}", s.ServerAutoStart);
System.Console.WriteLine("运行状态:{0}", s.State.ToString()); System.Console.WriteLine("网站绑定:");
foreach (var tmp in s.Bindings)
{
System.Console.WriteLine("\t类型:{0}", tmp.Protocol);
System.Console.WriteLine("\tIP 地址:{0}", tmp.EndPoint.Address.ToString());
System.Console.WriteLine("\t端口:{0}", tmp.EndPoint.Port.ToString());
System.Console.WriteLine("\t主机名:{0}", tmp.Host);
//System.Console.WriteLine(tmp.BindingInformation);
//System.Console.WriteLine(tmp.CertificateStoreName);
//System.Console.WriteLine(tmp.IsIPPortHostBinding);
//System.Console.WriteLine(tmp.IsLocallyStored);
//System.Console.WriteLine(tmp.UseDsMapper);
} System.Console.WriteLine("连接限制:");
System.Console.WriteLine("\t连接超时(秒):{0}", s.Limits.ConnectionTimeout.TotalSeconds);
System.Console.WriteLine("\t最大并发连接数:{0}", s.Limits.MaxConnections);
System.Console.WriteLine("\t最大带宽(字节/秒):{0}", s.Limits.MaxBandwidth); System.Console.WriteLine("失败请求跟踪:");
System.Console.WriteLine("\t跟踪文件的最大数量:{0}", s.TraceFailedRequestsLogging.MaxLogFiles);
System.Console.WriteLine("\t目录:{0}", s.TraceFailedRequestsLogging.Directory);
System.Console.WriteLine("\t已启用:{0}", s.TraceFailedRequestsLogging.Enabled); System.Console.WriteLine("日志:");
//System.Console.WriteLine("\t启用日志服务:{0}", s.LogFile.Enabled);
System.Console.WriteLine("\t格式:{0}", s.LogFile.LogFormat.ToString());
System.Console.WriteLine("\t目录:{0}", s.LogFile.Directory);
System.Console.WriteLine("\t文件包含字段:{0}", s.LogFile.LogExtFileFlags.ToString());
System.Console.WriteLine("\t计划:{0}", s.LogFile.Period.ToString());
System.Console.WriteLine("\t最大文件大小(字节):{0}", s.LogFile.TruncateSize);
System.Console.WriteLine("\t使用本地时间进行文件命名和滚动更新:{0}", s.LogFile.LocalTimeRollover); System.Console.WriteLine("----应用程序的默认应用程序池:{0}", s.ApplicationDefaults.ApplicationPoolName);
System.Console.WriteLine("----应用程序的默认已启用的协议:{0}", s.ApplicationDefaults.EnabledProtocols);
//System.Console.WriteLine("----应用程序的默认物理路径凭据:{0}", s.ApplicationDefaults.Methods.ToString());
//System.Console.WriteLine("----虚拟目录的默认物理路径凭据:{0}", s.VirtualDirectoryDefaults.Methods.ToString());
System.Console.WriteLine("----虚拟目录的默认物理路径凭据登录类型:{0}", s.VirtualDirectoryDefaults.LogonMethod.ToString());
System.Console.WriteLine("----虚拟目录的默认用户名:{0}", s.VirtualDirectoryDefaults.UserName);
System.Console.WriteLine("----虚拟目录的默认用户密码:{0}", s.VirtualDirectoryDefaults.Password);
System.Console.WriteLine("应用程序 列表:");
foreach (var tmp in s.Applications)
{
if (tmp.Path != "/")
{
System.Console.WriteLine("\t模式名:{0}", tmp.Schema.Name);
System.Console.WriteLine("\t虚拟路径:{0}", tmp.Path);
System.Console.WriteLine("\t物理路径:{0}", tmp.VirtualDirectories["/"].PhysicalPath);
//System.Console.WriteLine("\t物理路径凭据:{0}", tmp.Methods.ToString());
System.Console.WriteLine("\t应用程序池:{0}", tmp.ApplicationPoolName);
System.Console.WriteLine("\t已启用的协议:{0}", tmp.EnabledProtocols);
}
System.Console.WriteLine("\t虚拟目录 列表:");
foreach (var tmp2 in tmp.VirtualDirectories)
{
if (tmp2.Path != "/")
{
System.Console.WriteLine("\t\t模式名:{0}", tmp2.Schema.Name);
System.Console.WriteLine("\t\t虚拟路径:{0}", tmp2.Path);
System.Console.WriteLine("\t\t物理路径:{0}", tmp2.PhysicalPath);
//System.Console.WriteLine("\t\t物理路径凭据:{0}", tmp2.Methods.ToString());
System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", tmp2.LogonMethod.ToString());
}
}
}
}
 

C#操作IIS站点 Microsoft.Web.Administration.dll的更多相关文章

  1. C# IIS站点管理--Microsoft.Web.Administration.dll

    Microsoft中提供了管理IIS7及以上版本一个非常强大的API - Microsoft.Web.Administration.dll,利用该API可以让我们很方便的以编程的方式管理和设定IIS的 ...

  2. IIS 7管理API——Microsoft.Web.Administration介绍

    原文:http://www.cnblogs.com/dflying/archive/2006/04/17/377276.html 本文翻译整理自Carlos Aguilar Mares的blog文章: ...

  3. 使用 Microsoft.Web.Administration 管理iis

    How to Automate IIS 7 Configuration with .NET How to Automate IIS 7 Configuration with .NET Are you ...

  4. Microsoft.Web.Administration操作IIS7时的权限设置

    在用Microsoft.Web.Administration操作IIS7时,你可能会遇到如下权限错误: 文件名: redirection.config错误: 由于权限不足而无法读取配置文件 如下图: ...

  5. IIS7 Microsoft.Web.Administration 创建Application问题

    在使用DirectoryEntry操作IIS时,可以设置很多属性.但使用Microsoft.Web.Administration中的一些类时,不知道在哪设置.例如:AccessScript,Acces ...

  6. IIS7 开发与 管理 编程 之 Microsoft.Web.Administration

    一.引言: 关于IIS7 Mocrosoft.Web.Administration  网上这方面详细资料相对来说比较少,大家千篇一律的(都是一篇翻译过来的文章,msdn 里面的实列没有).前段做了一个 ...

  7. Microsoft.Web.Administration in IIS

    http://blogs.msdn.com/b/carlosag/archive/2006/04/17/microsoftwebadministration.aspx 最好使用在IIS8中,因为为每一 ...

  8. c#操作IIS站点

    /// <summary> /// 获取本地IIS版本 /// </summary> /// <returns></returns> public st ...

  9. C# 使用代码来操作 IIS

    由于需要维护网站的时候,可以自动将所有的站点HTTP重定向到指定的静态页面上. 要操作 IIS 主要使用到的是“Microsoft.Web.Administration.dll”. 该类库不可以在引用 ...

随机推荐

  1. IOS内存管理详解

    一.    基本原理 1.        什么是内存管理 移动设备的内存极其有限,每个app所能占用的内存是有限制的 当app所占用的内存较多时,系统会发出内存警告,这时得回收一些不需要再使用的内存空 ...

  2. flask 学习

    标题 操作 09-2-sqlalchemy数据库查询 (2019-01-18 23:30) 编辑 09-1-数据库扩展包flask-sqlalchemy (2019-01-18 17:53) 编辑 0 ...

  3. leetcode(java)

    86 class Solution { public ListNode partition(ListNode head, int x) { ListNode lowheader=new ListNod ...

  4. Alpha冲刺 - (4/10)

    Alpha冲刺 - (4/10)   Part.1 开篇 队名:彳艮彳亍团队 组长博客:戳我进入 作业博客:班级博客本次作业的链接 Part.2 成员汇报 组员1(组长)柯奇豪 过去两天完成了哪些任务 ...

  5. Qt中的CSS配置(QDarkStyleSheet)

    QDarkStylesheet gihub地址 https://github.com/ColinDuquesnoy/QDarkStyleSheet

  6. 深度学习框架caffe/CNTK/Tensorflow/Theano/Torch的对比

    在单GPU下,所有这些工具集都调用cuDNN,因此只要外层的计算或者内存分配差异不大其性能表现都差不多. Caffe: 1)主流工业级深度学习工具,具有出色的卷积神经网络实现.在计算机视觉领域Caff ...

  7. Swift5 语言指南(十三) 方法

    方法是与特定类型相关联的函数.类,结构和枚举都可以定义实例方法,这些方法封装了用于处理给定类型的实例的特定任务和功能.类,结构和枚举也可以定义类型方法,它们与类型本身相关联.类型方法类似于Object ...

  8. 分布式任务调度系统xxl-job源码探究(二、服务中心)

    接下来看下服务端代码 服务端源码 服务端通过管理quartz定时任务组件,分发任务 先从入口看起,由web.xml进入,可以看出,自己编写的代码从applicationcontext-xxl-job- ...

  9. 【转载】MyBatis JdbcType 与Oracle、MySql数据类型对应关系详解

    [原文链接]:MyBatis JdbcType 与Oracle.MySql数据类型对应关系详解 1. Mybatis JdbcType与Oracle.MySql数据类型对应列表 2. Mybatis ...

  10. Windows.UI.Cred.dll损坏导致不能设置 PIN 密码

    心血来潮,重装系统. 然后发现不能设置 PIN,UWP界面在输完两个PIN后直接卡死(第一次设置的时候不需要输入第一行的PIN) google无果,打开系统日志,发现 上网下载一个对应版本的Windo ...