我是靠谱客的博主 忧虑芹菜,最近开发中收集的这篇文章主要介绍c# iis,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

引用:using Microsoft.Web.Administration;
对C:WindowsSystem32inetsrvConfigredirection.config设置everyone访问权限,否则会出现权限不足无法访问配置文件的错误

网上找的代码:


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

最后

以上就是忧虑芹菜为你收集整理的c# iis的全部内容,希望文章能够帮你解决c# iis所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(36)

评论列表共有 0 条评论

立即
投稿
返回
顶部