Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 304377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:16:31+00:00 2026-05-12T07:16:31+00:00

I’ve enabled trace pageoutput=true in my web.config and I like the easy way it

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:16:31+00:00Added an answer on May 12, 2026 at 7:16 am

    You can get your own trace events from HttpContext.Current.Trace.TraceFinished. Unfortunately, the page tracing (which includes all the goodies of Forms, QueryString, etc.) is locked away in internal methods.

    If you’re okay with reflection, you can call it like:

    using (var htw = new System.Web.UI.Html32TextWriter(response.Output)) {
        typeof(TraceContext)
            .GetMethod("Render",BindingFlags.NonPublic | BindingFlags.Instance)
            .Invoke(HttpContext.Current.Trace, new object[] { htw });
    }
    

    Reflectoring over System.Web.TraceContext.EndRequest should give you enough to create your own TracingHttpHandler if you can’t use reflection.

    Edit:
    It looks like you forgot BindingFlags.Instance. Also, I’m guessing you changed using (var htw = ...) to using (object htw = ...) which would give you the “type must be implicitly convertible to IDisposable” error. If you can’t use var, then you’ll have to write it as using (Html32TextWriter htw = ...).

    Full sample:

    <%@ WebHandler Language="C#" Class="UploadHandler" %>
    
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Reflection;
    
    public class UploadHandler : IHttpHandler {
        public bool IsReusable { 
           get { return true; }
        }
    
        public void ProcessRequest(HttpContext context) {
           // the output will suck as text/plain - Render outputs HTML.
           context.Response.ContentType = "text/html"; 
           context.Response.Write("Hello World!");
    
           // depending on web.config settings, you may need to enable tracing manually
           HttpContext.Current.Trace.IsEnabled = true;
           // I had to write a custom trace message, or the Request context wasn't captured - YMMV
           HttpContext.Current.Trace.Write(null);
    
           using (Html32TextWriter htw = new Html32TextWriter(context.Response.Output)) {
              typeof(TraceContext)
                  .GetMethod("Render", BindingFlags.NonPublic | BindingFlags.Instance)
                 .Invoke(HttpContext.Current.Trace, new object[] { htw });
           } 
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.