Created
April 18, 2019 14:08
-
-
Save joymon/1ad706fbb4ecdd088a7da1f13bbf28c6 to your computer and use it in GitHub Desktop.
ASP.Net test page to dump all the request and environment for debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" Trace="true" TraceMode="SortByCategory" %> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title>ASP.NET Diagnostic Page</title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<% | |
void DumpIdentityAsTable(object identity) | |
{ | |
try | |
{ | |
Response.Write("<table>"); | |
System.Reflection.MemberInfo[] refl_WindowsIdenty_members = identity.GetType().FindMembers( | |
System.Reflection.MemberTypes.Property, | |
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, | |
delegate (System.Reflection.MemberInfo objMemberInfo, Object objSearch) { return true; }, | |
null); | |
foreach (System.Reflection.MemberInfo currentMemberInfo in refl_WindowsIdenty_members) | |
{ | |
string key = currentMemberInfo.Name, value = string.Empty; | |
System.Reflection.MethodInfo getAccessorInfo = ((System.Reflection.PropertyInfo)currentMemberInfo).GetGetMethod(); | |
value = GetObjectValueAsString(getAccessorInfo.Invoke(identity, null)); | |
Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td></tr>", key, value)); | |
} | |
} | |
catch { } | |
finally { Response.Write("</table>"); } | |
} | |
string GetObjectValueAsString(object obj) | |
{ | |
string value = string.Empty; | |
if (typeof(IEnumerable).IsInstanceOfType(obj) && !typeof(string).IsInstanceOfType(obj)) | |
{ | |
foreach (object item in (IEnumerable)obj) | |
{ | |
value += item.ToString() + "<br />"; | |
} | |
} | |
else | |
{ | |
value = obj.ToString(); | |
} | |
return value; | |
} | |
string GetAuthenticationMethod() | |
{ | |
try | |
{ | |
if (Request.ServerVariables["AUTH_TYPE"] == "Negotiate") | |
{ | |
if (Request.Headers["Authorization"].Length > 1000) | |
return "KERBEROS"; | |
else | |
return "NTLM"; | |
} | |
else return string.Empty; | |
} | |
catch { return string.Empty; } | |
} | |
%> | |
<h2>Environment Variables</h2> | |
<table> | |
<% | |
foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables()) | |
{ | |
Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td></tr>", entry.Key, entry.Value)); | |
} | |
%> | |
</table> | |
<h2>Request.Headers</h2> | |
<h2>Authentication</h2> | |
System.Environment.UserName = <%= System.Environment.UserName %><br /> | |
Request.ServerVariables["AUTH_TYPE"] = <%= Request.ServerVariables["AUTH_TYPE"] %><br /> | |
Request.ServerVariables["AUTH_USER"] = <%=Request.ServerVariables["AUTH_USER"] %><br /> | |
Authentication method = <%= GetAuthenticationMethod() %><br /> | |
HttpContext.Current.Request.LogonUserIdentity.Name = <%= HttpContext.Current.Request.LogonUserIdentity.Name %><br /> | |
HttpContext.Current.Request.IsAuthenticated = <%= HttpContext.Current.Request.IsAuthenticated %><br /> | |
HttpContext.Current.User.Identity.Name = <%= HttpContext.Current.User.Identity.Name %><br /> | |
<h3>Dumping HttpContext.Current.User.Identity</h3> | |
<%DumpIdentityAsTable(HttpContext.Current.User.Identity);%> | |
Security.Principal.WindowsIdentity.GetCurrent().Name= <%= System.Security.Principal.WindowsIdentity.GetCurrent().Name %><br /> | |
<h3>Dumping System.Security.Principal.WindowsIdentity.GetCurrent()</h3> | |
<%DumpIdentityAsTable(System.Security.Principal.WindowsIdentity.GetCurrent());%> | |
System.Threading.Thread.CurrentPrincipal.Identity.Name = <%= System.Threading.Thread.CurrentPrincipal.Identity.Name %><br /> | |
<h3>Dumping System.Threading.Thread.CurrentPrincipal.Identity</h3> | |
<% DumpIdentityAsTable(System.Threading.Thread.CurrentPrincipal.Identity); %> | |
<h2>Threading </h2> | |
System.Threading.Thread.CurrentThread.ManagedThreadId = <%= System.Threading.Thread.CurrentThread.ManagedThreadId %><br /> | |
System.Threading.Thread.CurrentThread.CurrentCulture.Name = <%= System.Threading.Thread.CurrentThread.CurrentCulture.Name %><br /> | |
<h2>Application</h2> | |
Request.ApplicationPath = <%= Request.ApplicationPath %><br /> | |
Request.PhysicalApplicationPath = <%= Request.PhysicalApplicationPath %><br /> | |
Request.PhysicalPath = <%= Request.PhysicalPath %><br /> | |
<h2>Misc</h2> | |
Response.Filter = <%= Request.Filter.ToString() %><br /> | |
Request.UrlReferrer = <%= Request.UrlReferrer %><br /> | |
Request.UserLanguages = <%= string.Join(",", (Request.UserLanguages ?? new string[0])) %><br /> | |
</form> | |
<h2>Trace details</h2> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment