设为首页 收藏本站
查看: 803|回复: 0

[经验分享] C#操作IIS站点 Microsoft.Web.Administration.dll

[复制链接]

尚未签到

发表于 2017-12-27 15:37:24 | 显示全部楼层 |阅读模式
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());
  }
  }
  }
  }

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-428659-1-1.html 上篇帖子: 利用Advanced Installer将asp.netMVC连同IIS服务和mysql数据库一块打包成exe安装包 下篇帖子: IIS Web 服务器/ASP.NET 运行原理基本知识概念整理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表