LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

[点晴永久免费OA]C#操作IIS站点Microsoft.Web.Administration.dll

admin
2023年1月19日 0:54 本文热度 1099

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

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



主要调用code 如下:

  1. using (ServerManager sm = ServerManager.OpenRemote("192.168.0.129"))
  2. {
  3. //创建站点
  4. sm.Sites.Add("test", @"D:\DataBackup", 9898);
  5. //创建应用程序池
  6. sm.ApplicationPools.Add("test");
  7. //设置站点的应用程序池
  8. sm.Sites["test"].Applications[0].ApplicationPoolName = "test";
  9. sm.CommitChanges();
  10. }
  1. void createIISSite(string serverIP, string webName, int port, string path)
  2. {
  3. try
  4. {
  5. using (ServerManager sm = ServerManager.OpenRemote(serverIP))
  6. {
  7. //创建应用程序池
  8. ApplicationPool appPool = sm.ApplicationPools.FirstOrDefault(x => x.Name == webName);
  9. if (appPool == null)
  10. {
  11. appPool = sm.ApplicationPools.Add(webName);
  12. appPool.AutoStart = false;
  13.  
  14. appPool.QueueLength = 10000;
  15. appPool.StartMode = StartMode.AlwaysRunning;//启动模式
  16. appPool.Recycling.PeriodicRestart.Time = new TimeSpan();//回收时间间隔
  17. appPool.ProcessModel.IdleTimeout = new TimeSpan();//闲置超时
  18. appPool.ProcessModel.MaxProcesses = 1;//最大工作进程数
  19. }
  20. //创建Site
  21. Site site = sm.Sites.FirstOrDefault(x => x.Name == webName);
  22. if (site == null)
  23. {
  24. site = sm.Sites.Add(webName, path, port);
  25. site.ServerAutoStart = true;
  26.  
  27. site.Bindings[0].EndPoint.Port = port;
  28. Application root = site.Applications["/"];
  29. root.ApplicationPoolName = webName;
  30. root.VirtualDirectories["/"].PhysicalPath = path;
  31. root.SetAttributeValue("preloadEnabled", true); /*预加载*/
  32. }
  33. sm.CommitChanges();
  34. }
  35.  
  36. }
  37. catch (Exception ex)
  38. {
  39. ExceptionUtil.Throw(ex);
  40. }
  41.  
  42. }

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

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

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

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

  1. Microsoft.Web.Administration.ServerManager sm = new Microsoft.Web.Administration.ServerManager();
  2.  
  3. System.Console.WriteLine("应用程序池默认设置:");
  4. System.Console.WriteLine("\t常规:");
  5. System.Console.WriteLine("\t\t.NET Framework 版本:{0}", sm.ApplicationPoolDefaults.ManagedRuntimeVersion);
  6. System.Console.WriteLine("\t\t队列长度:{0}", sm.ApplicationPoolDefaults.QueueLength);
  7. System.Console.WriteLine("\t\t托管管道模式:{0}", sm.ApplicationPoolDefaults.ManagedPipelineMode.ToString());
  8. System.Console.WriteLine("\t\t自动启动:{0}", sm.ApplicationPoolDefaults.AutoStart);
  9.  
  10. System.Console.WriteLine("\tCPU:");
  11. System.Console.WriteLine("\t\t处理器关联掩码:{0}", sm.ApplicationPoolDefaults.Cpu.SmpProcessorAffinityMask);
  12. System.Console.WriteLine("\t\t限制:{0}", sm.ApplicationPoolDefaults.Cpu.Limit);
  13. System.Console.WriteLine("\t\t限制操作:{0}", sm.ApplicationPoolDefaults.Cpu.Action.ToString());
  14. System.Console.WriteLine("\t\t限制间隔(分钟):{0}", sm.ApplicationPoolDefaults.Cpu.ResetInterval.TotalMinutes);
  15. System.Console.WriteLine("\t\t已启用处理器关联:{0}", sm.ApplicationPoolDefaults.Cpu.SmpAffinitized);
  16.  
  17. System.Console.WriteLine("\t回收:");
  18. System.Console.WriteLine("\t\t发生配置更改时禁止回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowRotationOnConfigChange);
  19. System.Console.WriteLine("\t\t固定时间间隔(分钟):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Time.TotalMinutes);
  20. System.Console.WriteLine("\t\t禁用重叠回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowOverlappingRotation);
  21. System.Console.WriteLine("\t\t请求限制:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Requests);
  22. System.Console.WriteLine("\t\t虚拟内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Memory);
  23. System.Console.WriteLine("\t\t专用内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.PrivateMemory);
  24. System.Console.WriteLine("\t\t特定时间:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Schedule.ToString());
  25. System.Console.WriteLine("\t\t生成回收事件日志条目:{0}", sm.ApplicationPoolDefaults.Recycling.LogEventOnRecycle.ToString());
  26.  
  27. System.Console.WriteLine("\t进程孤立:");
  28. System.Console.WriteLine("\t\t可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionExe);
  29. System.Console.WriteLine("\t\t可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionParams);
  30. System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.OrphanWorkerProcess);
  31.  
  32. System.Console.WriteLine("\t进程模型:");
  33. System.Console.WriteLine("\t\tPing 间隔(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingInterval.TotalSeconds);
  34. System.Console.WriteLine("\t\tPing 最大响应时间(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingResponseTime.TotalSeconds);
  35. System.Console.WriteLine("\t\t标识:{0}", sm.ApplicationPoolDefaults.ProcessModel.IdentityType);
  36. System.Console.WriteLine("\t\t用户名:{0}", sm.ApplicationPoolDefaults.ProcessModel.UserName);
  37. System.Console.WriteLine("\t\t密码:{0}", sm.ApplicationPoolDefaults.ProcessModel.Password);
  38. System.Console.WriteLine("\t\t关闭时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.ShutdownTimeLimit.TotalSeconds);
  39. System.Console.WriteLine("\t\t加载用户配置文件:{0}", sm.ApplicationPoolDefaults.ProcessModel.LoadUserProfile);
  40. System.Console.WriteLine("\t\t启动时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.StartupTimeLimit.TotalSeconds);
  41. System.Console.WriteLine("\t\t允许 Ping:{0}", sm.ApplicationPoolDefaults.ProcessModel.PingingEnabled);
  42. System.Console.WriteLine("\t\t闲置超时(分钟):{0}", sm.ApplicationPoolDefaults.ProcessModel.IdleTimeout.TotalMinutes);
  43. System.Console.WriteLine("\t\t最大工作进程数:{0}", sm.ApplicationPoolDefaults.ProcessModel.MaxProcesses);
  44.  
  45. System.Console.WriteLine("\t快速故障防护:");
  46. System.Console.WriteLine("\t\t“服务不可用”响应类型:{0}", sm.ApplicationPoolDefaults.Failure.LoadBalancerCapabilities.ToString());
  47. System.Console.WriteLine("\t\t故障间隔(分钟):{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionInterval.TotalMinutes);
  48. System.Console.WriteLine("\t\t关闭可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownExe);
  49. System.Console.WriteLine("\t\t关闭可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownParams);
  50. System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtection);
  51. System.Console.WriteLine("\t\t最大故障数:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionMaxCrashes);
  52. System.Console.WriteLine("\t\t允许32位应用程序运行在64位 Windows 上:{0}", sm.ApplicationPoolDefaults.Enable32BitAppOnWin64);
  53.  
  54. System.Console.WriteLine();
  55. System.Console.WriteLine("网站默认设置:");
  56. System.Console.WriteLine("\t常规:");
  57. System.Console.WriteLine("\t\t物理路径凭据:UserName={0}, Password={1}", sm.VirtualDirectoryDefaults.UserName, sm.VirtualDirectoryDefaults.Password);
  58. System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", sm.VirtualDirectoryDefaults.LogonMethod.ToString());
  59. System.Console.WriteLine("\t\t应用程序池:{0}", sm.ApplicationDefaults.ApplicationPoolName);
  60. System.Console.WriteLine("\t\t自动启动:{0}", sm.SiteDefaults.ServerAutoStart);
  61. System.Console.WriteLine("\t行为:");
  62. System.Console.WriteLine("\t\t连接限制:");
  63. System.Console.WriteLine("\t\t\t连接超时(秒):{0}", sm.SiteDefaults.Limits.ConnectionTimeout.TotalSeconds);
  64. System.Console.WriteLine("\t\t\t最大并发连接数:{0}", sm.SiteDefaults.Limits.MaxConnections);
  65. System.Console.WriteLine("\t\t\t最大带宽(字节/秒):{0}", sm.SiteDefaults.Limits.MaxBandwidth);
  66. System.Console.WriteLine("\t\t失败请求跟踪:");
  67. System.Console.WriteLine("\t\t\t跟踪文件的最大数量:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.MaxLogFiles);
  68. System.Console.WriteLine("\t\t\t目录:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Directory);
  69. System.Console.WriteLine("\t\t\t已启用:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Enabled);
  70. System.Console.WriteLine("\t\t已启用的协议:{0}", sm.ApplicationDefaults.EnabledProtocols);
  71.  
  72. foreach (var s in sm.Sites)//遍历网站
  73. {
  74. System.Console.WriteLine();
  75. System.Console.WriteLine("模式名:{0}", s.Schema.Name);
  76. System.Console.WriteLine("编号:{0}", s.Id);
  77. System.Console.WriteLine("网站名称:{0}", s.Name);
  78. System.Console.WriteLine("物理路径:{0}", s.Applications["/"].VirtualDirectories["/"].PhysicalPath);
  79. System.Console.WriteLine("物理路径凭据:{0}", s.Methods.ToString());
  80. System.Console.WriteLine("应用程序池:{0}", s.Applications["/"].ApplicationPoolName);
  81. System.Console.WriteLine("已启用的协议:{0}", s.Applications["/"].EnabledProtocols);
  82. System.Console.WriteLine("自动启动:{0}", s.ServerAutoStart);
  83. System.Console.WriteLine("运行状态:{0}", s.State.ToString());
  84.  
  85. System.Console.WriteLine("网站绑定:");
  86. foreach (var tmp in s.Bindings)
  87. {
  88. System.Console.WriteLine("\t类型:{0}", tmp.Protocol);
  89. System.Console.WriteLine("\tIP 地址:{0}", tmp.EndPoint.Address.ToString());
  90. System.Console.WriteLine("\t端口:{0}", tmp.EndPoint.Port.ToString());
  91. System.Console.WriteLine("\t主机名:{0}", tmp.Host);
  92. //System.Console.WriteLine(tmp.BindingInformation);
  93. //System.Console.WriteLine(tmp.CertificateStoreName);
  94. //System.Console.WriteLine(tmp.IsIPPortHostBinding);
  95. //System.Console.WriteLine(tmp.IsLocallyStored);
  96. //System.Console.WriteLine(tmp.UseDsMapper);
  97. }
  98.  
  99. System.Console.WriteLine("连接限制:");
  100. System.Console.WriteLine("\t连接超时(秒):{0}", s.Limits.ConnectionTimeout.TotalSeconds);
  101. System.Console.WriteLine("\t最大并发连接数:{0}", s.Limits.MaxConnections);
  102. System.Console.WriteLine("\t最大带宽(字节/秒):{0}", s.Limits.MaxBandwidth);
  103.  
  104. System.Console.WriteLine("失败请求跟踪:");
  105. System.Console.WriteLine("\t跟踪文件的最大数量:{0}", s.TraceFailedRequestsLogging.MaxLogFiles);
  106. System.Console.WriteLine("\t目录:{0}", s.TraceFailedRequestsLogging.Directory);
  107. System.Console.WriteLine("\t已启用:{0}", s.TraceFailedRequestsLogging.Enabled);
  108.  
  109. System.Console.WriteLine("日志:");
  110. //System.Console.WriteLine("\t启用日志服务:{0}", s.LogFile.Enabled);
  111. System.Console.WriteLine("\t格式:{0}", s.LogFile.LogFormat.ToString());
  112. System.Console.WriteLine("\t目录:{0}", s.LogFile.Directory);
  113. System.Console.WriteLine("\t文件包含字段:{0}", s.LogFile.LogExtFileFlags.ToString());
  114. System.Console.WriteLine("\t计划:{0}", s.LogFile.Period.ToString());
  115. System.Console.WriteLine("\t最大文件大小(字节):{0}", s.LogFile.truncateSize);
  116. System.Console.WriteLine("\t使用本地时间进行文件命名和滚动更新:{0}", s.LogFile.LocalTimeRollover);
  117.  
  118. System.Console.WriteLine("----应用程序的默认应用程序池:{0}", s.ApplicationDefaults.ApplicationPoolName);
  119. System.Console.WriteLine("----应用程序的默认已启用的协议:{0}", s.ApplicationDefaults.EnabledProtocols);
  120. //System.Console.WriteLine("----应用程序的默认物理路径凭据:{0}", s.ApplicationDefaults.Methods.ToString());
  121. //System.Console.WriteLine("----虚拟目录的默认物理路径凭据:{0}", s.VirtualDirectoryDefaults.Methods.ToString());
  122. System.Console.WriteLine("----虚拟目录的默认物理路径凭据登录类型:{0}", s.VirtualDirectoryDefaults.LogonMethod.ToString());
  123. System.Console.WriteLine("----虚拟目录的默认用户名:{0}", s.VirtualDirectoryDefaults.UserName);
  124. System.Console.WriteLine("----虚拟目录的默认用户密码:{0}", s.VirtualDirectoryDefaults.Password);
  125. System.Console.WriteLine("应用程序 列表:");
  126. foreach (var tmp in s.Applications)
  127. {
  128. if (tmp.Path != "/")
  129. {
  130. System.Console.WriteLine("\t模式名:{0}", tmp.Schema.Name);
  131. System.Console.WriteLine("\t虚拟路径:{0}", tmp.Path);
  132. System.Console.WriteLine("\t物理路径:{0}", tmp.VirtualDirectories["/"].PhysicalPath);
  133. //System.Console.WriteLine("\t物理路径凭据:{0}", tmp.Methods.ToString());
  134. System.Console.WriteLine("\t应用程序池:{0}", tmp.ApplicationPoolName);
  135. System.Console.WriteLine("\t已启用的协议:{0}", tmp.EnabledProtocols);
  136. }
  137. System.Console.WriteLine("\t虚拟目录 列表:");
  138. foreach (var tmp2 in tmp.VirtualDirectories)
  139. {
  140. if (tmp2.Path != "/")
  141. {
  142. System.Console.WriteLine("\t\t模式名:{0}", tmp2.Schema.Name);
  143. System.Console.WriteLine("\t\t虚拟路径:{0}", tmp2.Path);
  144. System.Console.WriteLine("\t\t物理路径:{0}", tmp2.PhysicalPath);
  145. //System.Console.WriteLine("\t\t物理路径凭据:{0}", tmp2.Methods.ToString());
  146. System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", tmp2.LogonMethod.ToString());
  147. }
  148. }
  149. }
  150. }
  1. Microsoft.Web.Administration.ServerManager sm = new Microsoft.Web.Administration.ServerManager();
  2.  
  3. System.Console.WriteLine("应用程序池默认设置:");
  4. System.Console.WriteLine("\t常规:");
  5. System.Console.WriteLine("\t\t.NET Framework 版本:{0}", sm.ApplicationPoolDefaults.ManagedRuntimeVersion);
  6. System.Console.WriteLine("\t\t队列长度:{0}", sm.ApplicationPoolDefaults.QueueLength);
  7. System.Console.WriteLine("\t\t托管管道模式:{0}", sm.ApplicationPoolDefaults.ManagedPipelineMode.ToString());
  8. System.Console.WriteLine("\t\t自动启动:{0}", sm.ApplicationPoolDefaults.AutoStart);
  9.  
  10. System.Console.WriteLine("\tCPU:");
  11. System.Console.WriteLine("\t\t处理器关联掩码:{0}", sm.ApplicationPoolDefaults.Cpu.SmpProcessorAffinityMask);
  12. System.Console.WriteLine("\t\t限制:{0}", sm.ApplicationPoolDefaults.Cpu.Limit);
  13. System.Console.WriteLine("\t\t限制操作:{0}", sm.ApplicationPoolDefaults.Cpu.Action.ToString());
  14. System.Console.WriteLine("\t\t限制间隔(分钟):{0}", sm.ApplicationPoolDefaults.Cpu.ResetInterval.TotalMinutes);
  15. System.Console.WriteLine("\t\t已启用处理器关联:{0}", sm.ApplicationPoolDefaults.Cpu.SmpAffinitized);
  16.  
  17. System.Console.WriteLine("\t回收:");
  18. System.Console.WriteLine("\t\t发生配置更改时禁止回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowRotationOnConfigChange);
  19. System.Console.WriteLine("\t\t固定时间间隔(分钟):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Time.TotalMinutes);
  20. System.Console.WriteLine("\t\t禁用重叠回收:{0}", sm.ApplicationPoolDefaults.Recycling.DisallowOverlappingRotation);
  21. System.Console.WriteLine("\t\t请求限制:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Requests);
  22. System.Console.WriteLine("\t\t虚拟内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Memory);
  23. System.Console.WriteLine("\t\t专用内存限制(KB):{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.PrivateMemory);
  24. System.Console.WriteLine("\t\t特定时间:{0}", sm.ApplicationPoolDefaults.Recycling.PeriodicRestart.Schedule.ToString());
  25. System.Console.WriteLine("\t\t生成回收事件日志条目:{0}", sm.ApplicationPoolDefaults.Recycling.LogEventOnRecycle.ToString());
  26.  
  27. System.Console.WriteLine("\t进程孤立:");
  28. System.Console.WriteLine("\t\t可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionExe);
  29. System.Console.WriteLine("\t\t可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.OrphanActionParams);
  30. System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.OrphanWorkerProcess);
  31.  
  32. System.Console.WriteLine("\t进程模型:");
  33. System.Console.WriteLine("\t\tPing 间隔(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingInterval.TotalSeconds);
  34. System.Console.WriteLine("\t\tPing 最大响应时间(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.PingResponseTime.TotalSeconds);
  35. System.Console.WriteLine("\t\t标识:{0}", sm.ApplicationPoolDefaults.ProcessModel.IdentityType);
  36. System.Console.WriteLine("\t\t用户名:{0}", sm.ApplicationPoolDefaults.ProcessModel.UserName);
  37. System.Console.WriteLine("\t\t密码:{0}", sm.ApplicationPoolDefaults.ProcessModel.Password);
  38. System.Console.WriteLine("\t\t关闭时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.ShutdownTimeLimit.TotalSeconds);
  39. System.Console.WriteLine("\t\t加载用户配置文件:{0}", sm.ApplicationPoolDefaults.ProcessModel.LoadUserProfile);
  40. System.Console.WriteLine("\t\t启动时间限制(秒):{0}", sm.ApplicationPoolDefaults.ProcessModel.StartupTimeLimit.TotalSeconds);
  41. System.Console.WriteLine("\t\t允许 Ping:{0}", sm.ApplicationPoolDefaults.ProcessModel.PingingEnabled);
  42. System.Console.WriteLine("\t\t闲置超时(分钟):{0}", sm.ApplicationPoolDefaults.ProcessModel.IdleTimeout.TotalMinutes);
  43. System.Console.WriteLine("\t\t最大工作进程数:{0}", sm.ApplicationPoolDefaults.ProcessModel.MaxProcesses);
  44.  
  45. System.Console.WriteLine("\t快速故障防护:");
  46. System.Console.WriteLine("\t\t“服务不可用”响应类型:{0}", sm.ApplicationPoolDefaults.Failure.LoadBalancerCapabilities.ToString());
  47. System.Console.WriteLine("\t\t故障间隔(分钟):{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionInterval.TotalMinutes);
  48. System.Console.WriteLine("\t\t关闭可执行文件:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownExe);
  49. System.Console.WriteLine("\t\t关闭可执行文件参数:{0}", sm.ApplicationPoolDefaults.Failure.AutoShutdownParams);
  50. System.Console.WriteLine("\t\t已启用:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtection);
  51. System.Console.WriteLine("\t\t最大故障数:{0}", sm.ApplicationPoolDefaults.Failure.RapidFailProtectionMaxCrashes);
  52. System.Console.WriteLine("\t\t允许32位应用程序运行在64位 Windows 上:{0}", sm.ApplicationPoolDefaults.Enable32BitAppOnWin64);
  53.  
  54. System.Console.WriteLine();
  55. System.Console.WriteLine("网站默认设置:");
  56. System.Console.WriteLine("\t常规:");
  57. System.Console.WriteLine("\t\t物理路径凭据:UserName={0}, Password={1}", sm.VirtualDirectoryDefaults.UserName, sm.VirtualDirectoryDefaults.Password);
  58. System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", sm.VirtualDirectoryDefaults.LogonMethod.ToString());
  59. System.Console.WriteLine("\t\t应用程序池:{0}", sm.ApplicationDefaults.ApplicationPoolName);
  60. System.Console.WriteLine("\t\t自动启动:{0}", sm.SiteDefaults.ServerAutoStart);
  61. System.Console.WriteLine("\t行为:");
  62. System.Console.WriteLine("\t\t连接限制:");
  63. System.Console.WriteLine("\t\t\t连接超时(秒):{0}", sm.SiteDefaults.Limits.ConnectionTimeout.TotalSeconds);
  64. System.Console.WriteLine("\t\t\t最大并发连接数:{0}", sm.SiteDefaults.Limits.MaxConnections);
  65. System.Console.WriteLine("\t\t\t最大带宽(字节/秒):{0}", sm.SiteDefaults.Limits.MaxBandwidth);
  66. System.Console.WriteLine("\t\t失败请求跟踪:");
  67. System.Console.WriteLine("\t\t\t跟踪文件的最大数量:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.MaxLogFiles);
  68. System.Console.WriteLine("\t\t\t目录:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Directory);
  69. System.Console.WriteLine("\t\t\t已启用:{0}", sm.SiteDefaults.TraceFailedRequestsLogging.Enabled);
  70. System.Console.WriteLine("\t\t已启用的协议:{0}", sm.ApplicationDefaults.EnabledProtocols);
  71.  
  72. foreach (var s in sm.Sites)//遍历网站
  73. {
  74. System.Console.WriteLine();
  75. System.Console.WriteLine("模式名:{0}", s.Schema.Name);
  76. System.Console.WriteLine("编号:{0}", s.Id);
  77. System.Console.WriteLine("网站名称:{0}", s.Name);
  78. System.Console.WriteLine("物理路径:{0}", s.Applications["/"].VirtualDirectories["/"].PhysicalPath);
  79. System.Console.WriteLine("物理路径凭据:{0}", s.Methods.ToString());
  80. System.Console.WriteLine("应用程序池:{0}", s.Applications["/"].ApplicationPoolName);
  81. System.Console.WriteLine("已启用的协议:{0}", s.Applications["/"].EnabledProtocols);
  82. System.Console.WriteLine("自动启动:{0}", s.ServerAutoStart);
  83. System.Console.WriteLine("运行状态:{0}", s.State.ToString());
  84.  
  85. System.Console.WriteLine("网站绑定:");
  86. foreach (var tmp in s.Bindings)
  87. {
  88. System.Console.WriteLine("\t类型:{0}", tmp.Protocol);
  89. System.Console.WriteLine("\tIP 地址:{0}", tmp.EndPoint.Address.ToString());
  90. System.Console.WriteLine("\t端口:{0}", tmp.EndPoint.Port.ToString());
  91. System.Console.WriteLine("\t主机名:{0}", tmp.Host);
  92. //System.Console.WriteLine(tmp.BindingInformation);
  93. //System.Console.WriteLine(tmp.CertificateStoreName);
  94. //System.Console.WriteLine(tmp.IsIPPortHostBinding);
  95. //System.Console.WriteLine(tmp.IsLocallyStored);
  96. //System.Console.WriteLine(tmp.UseDsMapper);
  97. }
  98.  
  99. System.Console.WriteLine("连接限制:");
  100. System.Console.WriteLine("\t连接超时(秒):{0}", s.Limits.ConnectionTimeout.TotalSeconds);
  101. System.Console.WriteLine("\t最大并发连接数:{0}", s.Limits.MaxConnections);
  102. System.Console.WriteLine("\t最大带宽(字节/秒):{0}", s.Limits.MaxBandwidth);
  103.  
  104. System.Console.WriteLine("失败请求跟踪:");
  105. System.Console.WriteLine("\t跟踪文件的最大数量:{0}", s.TraceFailedRequestsLogging.MaxLogFiles);
  106. System.Console.WriteLine("\t目录:{0}", s.TraceFailedRequestsLogging.Directory);
  107. System.Console.WriteLine("\t已启用:{0}", s.TraceFailedRequestsLogging.Enabled);
  108.  
  109. System.Console.WriteLine("日志:");
  110. //System.Console.WriteLine("\t启用日志服务:{0}", s.LogFile.Enabled);
  111. System.Console.WriteLine("\t格式:{0}", s.LogFile.LogFormat.ToString());
  112. System.Console.WriteLine("\t目录:{0}", s.LogFile.Directory);
  113. System.Console.WriteLine("\t文件包含字段:{0}", s.LogFile.LogExtFileFlags.ToString());
  114. System.Console.WriteLine("\t计划:{0}", s.LogFile.Period.ToString());
  115. System.Console.WriteLine("\t最大文件大小(字节):{0}", s.LogFile.truncateSize);
  116. System.Console.WriteLine("\t使用本地时间进行文件命名和滚动更新:{0}", s.LogFile.LocalTimeRollover);
  117.  
  118. System.Console.WriteLine("----应用程序的默认应用程序池:{0}", s.ApplicationDefaults.ApplicationPoolName);
  119. System.Console.WriteLine("----应用程序的默认已启用的协议:{0}", s.ApplicationDefaults.EnabledProtocols);
  120. //System.Console.WriteLine("----应用程序的默认物理路径凭据:{0}", s.ApplicationDefaults.Methods.ToString());
  121. //System.Console.WriteLine("----虚拟目录的默认物理路径凭据:{0}", s.VirtualDirectoryDefaults.Methods.ToString());
  122. System.Console.WriteLine("----虚拟目录的默认物理路径凭据登录类型:{0}", s.VirtualDirectoryDefaults.LogonMethod.ToString());
  123. System.Console.WriteLine("----虚拟目录的默认用户名:{0}", s.VirtualDirectoryDefaults.UserName);
  124. System.Console.WriteLine("----虚拟目录的默认用户密码:{0}", s.VirtualDirectoryDefaults.Password);
  125. System.Console.WriteLine("应用程序 列表:");
  126. foreach (var tmp in s.Applications)
  127. {
  128. if (tmp.Path != "/")
  129. {
  130. System.Console.WriteLine("\t模式名:{0}", tmp.Schema.Name);
  131. System.Console.WriteLine("\t虚拟路径:{0}", tmp.Path);
  132. System.Console.WriteLine("\t物理路径:{0}", tmp.VirtualDirectories["/"].PhysicalPath);
  133. //System.Console.WriteLine("\t物理路径凭据:{0}", tmp.Methods.ToString());
  134. System.Console.WriteLine("\t应用程序池:{0}", tmp.ApplicationPoolName);
  135. System.Console.WriteLine("\t已启用的协议:{0}", tmp.EnabledProtocols);
  136. }
  137. System.Console.WriteLine("\t虚拟目录 列表:");
  138. foreach (var tmp2 in tmp.VirtualDirectories)
  139. {
  140. if (tmp2.Path != "/")
  141. {
  142. System.Console.WriteLine("\t\t模式名:{0}", tmp2.Schema.Name);
  143. System.Console.WriteLine("\t\t虚拟路径:{0}", tmp2.Path);
  144. System.Console.WriteLine("\t\t物理路径:{0}", tmp2.PhysicalPath);
  145. //System.Console.WriteLine("\t\t物理路径凭据:{0}", tmp2.Methods.ToString());
  146. System.Console.WriteLine("\t\t物理路径凭据登录类型:{0}", tmp2.LogonMethod.ToString());
  147. }
  148. }
  149. }
  150. }

该文章在 2023/1/19 0:54:20 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved