httphandler to intercept pages before sent to user

G

Guest

We want to create server-side code that will retrieve the user requested
pages, then manipulate the content of those pages just before being sent back
to the user. We tried the following:

• User requests the page, call it http://www.test.com/testapp/test.aspx
• IIS receives the request
• HttpHandler is called for all .aspx files requested as defined in the
web.config file for this application
<httpHandlers>
<add verb="*" path="*.aspx" type = "httphandlerRedir.DomainHandler ,
httpHandleRedir" />
</httpHandlers>
• The handler acts on behalf of the user and makes the request for the
test.aspx web page

• The handler retrieves the content, changes the structure and layout, and
returns this to the user


In the second to last bullet above, … the request for the test.aspx
(GetRequest()) causes another invocation of the httphandler to start as a
different session.

How can the handler make this request without it causing an invocation of
the httpHandler method again?

Is there a method that can be called that will request the page as part of
the same session?

Again, the goal is to be able to manipulate the finally constructed user
pages just before each gets sent back to the user.

Thanks
RP
 
M

Matt Berther

Hello rpale,

You might try PageParser.GetCompiledPageInstance(url, context)... I'm not
sure if that's what you're after, but thats what the IHttpHandlerFactory
that handles Pages uses.
 
S

Steven Cheng[MSFT]

Thanks for Matt's suggestions.

Hi Rpale,

Yes, if you're using a HttpHandler to indirectly router the comming asp.net
request and forward it to different actual pages, you may need to use
Matt's suggestion that use the PageParser.GetCompiledPageInstance to
manually compiled the page and get the pagehandler and process the comming
request. However, from your description, you're only want to intercept the
page's output content before they're sent to the clientside.
I think currently we have the following means:
1. If you're not forced to do this in a central point, we can override a
page's Render method so that get the render out html there.

2. If you want to add a central/global hook that intercept all the page's
response content in an asp.net application, maybe we need to use a Response
Filter.

The following blog thread (from Dino Esposito's WebLog ) has mentioned this
and there are some the useful links there:

http://weblogs.asp.net/despos/archive/2004/06/01/145436.aspx

Hope helps. If anything unclear, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top