httphandler to intercept pages before sent to user

Discussion in 'ASP .Net' started by =?Utf-8?B?cnBhbGU=?=, Dec 15, 2004.

  1. 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
    =?Utf-8?B?cnBhbGU=?=, Dec 15, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?cnBhbGU=?=

    Matt Berther Guest

    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.

    --
    Matt Berther
    http://www.mattberther.com

    > 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
    Matt Berther, Dec 16, 2004
    #2
    1. Advertising

  3. 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.)
    Steven Cheng[MSFT], Dec 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adam Smith

    Intercept html before rendering

    Adam Smith, May 26, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    606
    Adam Smith
    May 27, 2004
  2. =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?=

    Can you intercept the url request before a 404 error occurs?

    =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?=, Jul 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    635
    Scott Allen
    Jul 14, 2004
  3. LP
    Replies:
    5
    Views:
    610
    Robbe Morris [C# MVP]
    Feb 19, 2005
  4. super todd
    Replies:
    1
    Views:
    593
    Bruce Barker
    May 23, 2005
  5. Gabriel Lacatus

    How to intercept the XML requests sent by the proxy?

    Gabriel Lacatus, May 9, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    399
    Steven Cheng[MSFT]
    May 10, 2006
Loading...

Share This Page