static private HttpRuntimeInfo ( ) : string>.IDictionary |
||
return | string>.IDictionary |
internal static IDictionary<string, string> HttpRuntimeInfo()
{
IDictionary<string, string> info = new Dictionary<string, string>();
// todo: better way to deal with security; query config for trust level?
try
{
info.Add("CLR Install Directory", HttpRuntime.ClrInstallDirectory);
}
catch (SecurityException)
{
return info;
}
try
{
info.Add("Codegen Directory", HttpRuntime.CodegenDir);
info.Add("Bin Directory", HttpRuntime.BinDirectory);
info.Add("AppDomain Application Path", HttpRuntime.AppDomainAppPath);
}
catch (ArgumentException)
{
// do nothing
// These APIs don't check if path is set before setting security demands, which causes exception.
// So far this happens only when running from unit tests.
}
catch (NullReferenceException)
{
// do nothing
// These APIs don't check if path is set before setting security demands, which causes exception.
// So far this happens only when running from unit tests.
// Handling NRE is needed because of bug in .NET 4.6.2
}
info.Add("Asp Install Directory", HttpRuntime.AspInstallDirectory);
info.Add("Machine Configuration Directory", HttpRuntime.MachineConfigurationDirectory);
info.Add("AppDomain Id", HttpRuntime.AppDomainId);
info.Add("AppDomain Application Id", HttpRuntime.AppDomainAppId);
info.Add("AppDomain Application Virtual Path", HttpRuntime.AppDomainAppVirtualPath);
info.Add("Asp Client Script Physical Path", HttpRuntime.AspClientScriptPhysicalPath);
info.Add("Asp Client Script Virtual Path", HttpRuntime.AspClientScriptVirtualPath);
info.Add("Cache Size", HttpRuntime.Cache.Count.ToString(CultureInfo.InvariantCulture));
info.Add("Cache Effective Percentage Physical Memory Limit", HttpRuntime.Cache.EffectivePercentagePhysicalMemoryLimit.ToString(CultureInfo.InvariantCulture));
info.Add("Cache Effective Private Bytes Limit", HttpRuntime.Cache.EffectivePrivateBytesLimit.ToString(CultureInfo.InvariantCulture));
info.Add("On UNC Share", HttpRuntime.IsOnUNCShare.ToString());
return info;
}
public static HtmlString GetHtml() { StringBuilder sb = new StringBuilder(_Style); sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "<h1 class=\"server-info\">{0}</h1>", HttpUtility.HtmlEncode(HelpersResources.ServerInfo_Header))); var configuration = ServerInfo.Configuration(); Debug.Assert((configuration != null) && (configuration.Count > 0)); PrintInfoSection(sb, HttpUtility.HtmlEncode(HelpersResources.ServerInfo_ServerConfigTable), configuration); var serverVariables = ServerInfo.ServerVariables(); Debug.Assert((serverVariables != null)); PrintInfoSection(sb, HelpersResources.ServerInfo_ServerVars, serverVariables); var legacyCAS = ServerInfo.LegacyCAS(); if (legacyCAS.Any()) { PrintInfoSection(sb, HelpersResources.ServerInfo_LegacyCAS, legacyCAS); } // Info below is not available in medium trust. var httpRuntimeInfo = ServerInfo.HttpRuntimeInfo(); Debug.Assert(httpRuntimeInfo != null); if (!httpRuntimeInfo.Any()) { sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "<p class=\"server-info\">{0}</p>", HttpUtility.HtmlEncode(HelpersResources.ServerInfo_AdditionalInfo))); return(new HtmlString(sb.ToString())); } else { PrintInfoSection(sb, HelpersResources.ServerInfo_HttpRuntime, httpRuntimeInfo); var envVariables = ServerInfo.EnvironmentVariables(); Debug.Assert(envVariables != null); PrintInfoSection(sb, HelpersResources.ServerInfo_EnvVars, envVariables); } return(new HtmlString(sb.ToString())); }