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 7731529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:30:09+00:00 2026-06-01T06:30:09+00:00

I’m adding ASP.NET routing to an older webforms app. I’m using a custom HttpHandler

  • 0

I’m adding ASP.NET routing to an older webforms app. I’m using a custom HttpHandler to process everything. In some situations I would like to map a particular path back to an aspx file, so I need to just pass control back to the default HttpHandler for asp.net.

The closest I’ve gotten is this

public void ProcessRequest(HttpContext context) {
    // .. when we decide to pass it on

    var handler = new System.Web.UI.Page();
    handler.ProcessRequest(context);

    MemoryStream steam = new MemoryStream();
    StreamWriter writer = new StreamWriter(stream);
    HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
    handler.RenderControl(htmlWriter);


    // write headers, etc. & send stream to Response
}

It doesn’t do anything, there’s nothing output to the stream. MS’s documentation for System.Web.UI.Page (as an IHttpHandler) say something to the effect of “do not call the ProcessRequest method. It’s for internal use.”

From looking around it seems like you can do this with MVC, e.g. : MvcHttpHandler doesn't seem to implement IHttpHandler

There is also this thing System.Web.UI.PageHandlerFactory which appears that it would just produce a Page handler for an aspx file, but it’s internal and I can’t use it directly.

This page: http://msdn.microsoft.com/en-us/library/bb398986.aspx refers to the “default asp.net handler” but does not identify a class or give any indication how one might use it.

Any ideas on how I can do this? Is it possible?

  • 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-06-01T06:30:11+00:00Added an answer on June 1, 2026 at 6:30 am

    Persistence pays off! This actually works, and since this information seems to be available pretty much nowhere I thought I’d answer my own question. Thanks to Robert for this post on instantiating things with internal constructors, this is the key.

    http://www.rvenables.com/2009/08/instantiating-classes-with-internal-constructors/

    public void ProcessRequest(HttpContext context) {
        // the internal constructor doesn't do anything but prevent you from instantiating
        // the factory, so we can skip it.
        PageHandlerFactory factory =
            (PageHandlerFactory)System.Runtime.Serialization.FormatterServices
            .GetUninitializedObject(typeof(System.Web.UI.PageHandlerFactory));
    
         string newTarget  = "default.aspx"; 
         string newQueryString = // whatever you want
         string oldQueryString = context.Request.QueryString.ToString();
         string queryString = newQueryString + oldQueryString!="" ? 
             "&" + newQueryString :
             "";
    
         // the 3rd parameter must be just the file name.
         // the 4th parameter should be the physical path to the file, though it also
         //   works fine if you pass an empty string - perhaps that's only to override
         //   the usual presentation based on the path?
    
         var handler = factory.GetHandler(context, "GET",newTarget,
             context.Request.MapPath(context,newTarget));
    
         // Update the context object as it should appear to your page/app, and
         // assign your new handler.
    
         context.RewritePath(newTarget  , "", queryString);
         context.Handler = handler;
    
         // .. and done
    
         handler.ProcessRequest(context);
    }
    

    … and like some small miracle, an aspx page processes & renders completely in-process without the need to redirect.

    I expect this will only work in IIS7.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
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 have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.