I've enabled trace pageoutput="true" in my web.config and I like the easy way it provides of seeing all this stuff at the bottom of the page.
I'd like to get the same output from trace at the bottom of the output from my httphandler. Is there a way to dump out the same trace info via code that would follow this code:
public class UploadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
I particularly want to see the Forms and QueryString collections but all this gives is "Hello World".
-- edit update 7/25/2009:
public class UploadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
object htw = new System.Web.UI.Html32TextWriter(context.Response.Output);
{
typeof(TraceContext)
.GetMethod("Render", System.Reflection.BindingFlags.NonPublic)
.Invoke(HttpContext.Current.Trace, new object[] { htw });
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
I am also open to any other ideas about how to most easily get a formatted dump of the forms and querystring collections like pageOutput trace does.