Http Handler Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe Spooner

    #1

    Http Handler Question

    Hello,

    This may seem very obvious to someone else, but I'm at a loss for an
    answer to this problem.

    I have written an HttpHandler that opens up an html file and returns a
    string. This works great, but what if I have a file that is .aspx? I
    realize that I'm always going to get just straight text/string as my
    output, but I don't know what to look for or call in order to process
    the .aspx correctly.

    My goal is to have a url like http://www.website.com/mypage.html open
    up the file mypage.html and also wrap a design around it. The current
    method that I have in place works great for static navigation, but
    will not work for something that needs to be compiled by the aspnet
    dll.

    Below is a very simplified diagram of what I'm trying to do:

    -----------------------------------------------
    web.config is:
    ----------------
    <httpHandlers >
    <add verb="*" path="*.aspx,*. htm"
    type="CALS.Cals Handler,CalsHan dler" />
    </httpHandlers>

    -----------------------------------------------
    handler code is:
    ----------------
    public void ProcessRequest( HttpContext context)
    {
    HttpResponse objResponse = context.Respons e;
    HttpRequest objRequest = context.Request ;
    PageBuilder pgBuild = new PageBuilder();
    objResponse.Wri te(pgBuild.Buil d(objRequest.Ph ysicalApplicati onPath,
    objRequest.Phys icalPath));
    }
    -----------------------------------------------

    Note that PageBuilder is an object designed to create the output for
    the browser (string not aspx).

    Cheers!
    Joe
  • Brian W

    #2
    Re: Http Handler Question

    Take a look at
    PageParser.GetC ompiledPageInst ance

    Hope this helps
    Brian W



    "Joe Spooner" <jmspooner@ifas .ufl.edu> wrote in message
    news:14bd6da9.0 310230959.24bd6 88f@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > This may seem very obvious to someone else, but I'm at a loss for an
    > answer to this problem.
    >
    > I have written an HttpHandler that opens up an html file and returns a
    > string. This works great, but what if I have a file that is .aspx? I
    > realize that I'm always going to get just straight text/string as my
    > output, but I don't know what to look for or call in order to process
    > the .aspx correctly.
    >
    > My goal is to have a url like http://www.website.com/mypage.html open
    > up the file mypage.html and also wrap a design around it. The current
    > method that I have in place works great for static navigation, but
    > will not work for something that needs to be compiled by the aspnet
    > dll.
    >
    > Below is a very simplified diagram of what I'm trying to do:
    >
    > -----------------------------------------------
    > web.config is:
    > ----------------
    > <httpHandlers >
    > <add verb="*" path="*.aspx,*. htm"
    > type="CALS.Cals Handler,CalsHan dler" />
    > </httpHandlers>
    >
    > -----------------------------------------------
    > handler code is:
    > ----------------
    > public void ProcessRequest( HttpContext context)
    > {
    > HttpResponse objResponse = context.Respons e;
    > HttpRequest objRequest = context.Request ;
    > PageBuilder pgBuild = new PageBuilder();
    > objResponse.Wri te(pgBuild.Buil d(objRequest.Ph ysicalApplicati onPath,
    > objRequest.Phys icalPath));
    > }
    > -----------------------------------------------
    >
    > Note that PageBuilder is an object designed to create the output for
    > the browser (string not aspx).
    >
    > Cheers!
    > Joe[/color]


    Comment

    • SF

      #3
      Re: Http Handler Question

      You might wanna checkout Sitemesh.Net. It is providing you exactly with
      what you want, a page decorator: http://wiki.truemesh.com/sitemesh.net

      "Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
      news:uglqwGZmDH A.2536@tk2msftn gp13.phx.gbl...[color=blue]
      > Take a look at
      > PageParser.GetC ompiledPageInst ance
      >
      > Hope this helps
      > Brian W
      >
      >
      >
      > "Joe Spooner" <jmspooner@ifas .ufl.edu> wrote in message
      > news:14bd6da9.0 310230959.24bd6 88f@posting.goo gle.com...[color=green]
      > > Hello,
      > >
      > > This may seem very obvious to someone else, but I'm at a loss for an
      > > answer to this problem.
      > >
      > > I have written an HttpHandler that opens up an html file and returns a
      > > string. This works great, but what if I have a file that is .aspx? I
      > > realize that I'm always going to get just straight text/string as my
      > > output, but I don't know what to look for or call in order to process
      > > the .aspx correctly.
      > >
      > > My goal is to have a url like http://www.website.com/mypage.html open
      > > up the file mypage.html and also wrap a design around it. The current
      > > method that I have in place works great for static navigation, but
      > > will not work for something that needs to be compiled by the aspnet
      > > dll.
      > >
      > > Below is a very simplified diagram of what I'm trying to do:
      > >
      > > -----------------------------------------------
      > > web.config is:
      > > ----------------
      > > <httpHandlers >
      > > <add verb="*" path="*.aspx,*. htm"
      > > type="CALS.Cals Handler,CalsHan dler" />
      > > </httpHandlers>
      > >
      > > -----------------------------------------------
      > > handler code is:
      > > ----------------
      > > public void ProcessRequest( HttpContext context)
      > > {
      > > HttpResponse objResponse = context.Respons e;
      > > HttpRequest objRequest = context.Request ;
      > > PageBuilder pgBuild = new PageBuilder();
      > > objResponse.Wri te(pgBuild.Buil d(objRequest.Ph ysicalApplicati onPath,
      > > objRequest.Phys icalPath));
      > > }
      > > -----------------------------------------------
      > >
      > > Note that PageBuilder is an object designed to create the output for
      > > the browser (string not aspx).
      > >
      > > Cheers!
      > > Joe[/color]
      >
      >[/color]


      Comment

      • John Saunders

        #4
        Re: Http Handler Question

        "Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
        news:uglqwGZmDH A.2536@tk2msftn gp13.phx.gbl...[color=blue]
        > Take a look at
        > PageParser.GetC ompiledPageInst ance[/color]

        Brian, we should remind people that "This member supports the .NET Framework
        infrastructure and is not intended to be used directly from your code.".

        Of course, I use it also, in the absence of any
        "GetTheStandard HttpHandlerFor" method. Take a hint, Microsoft!
        --
        John


        Comment

        • Joe Spooner

          #5
          Re: Http Handler Question

          John,

          I agree with you totally. If I could implement something like
          GetTheStandardH ttpHandlerFor, then I would feel a lot happier about
          putting this into a large web application.

          For now my best solution is to use the following design (aka -
          band-aid):

          1. Catch .html extension
          2. Use a template (aspx) to open the html file and also provide the
          design for content by using the PageParser.GetC ompiledPageInst ance. I
          create a querystring off of the .html file name & directory and pull
          the file out that way.

          This is truly not cool and not elegant, but I know it will work. I
          hope Microsoft catches on to this and makes some changes so that web
          app's and web sites can be more object oriented (at least in my
          limited perspective).

          Thanks,
          Joe

          "John Saunders" <john.saunder s at surfcontrol.com > wrote in message news:<#1PfpolmD HA.372@TK2MSFTN GP11.phx.gbl>.. .[color=blue]
          > "Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
          > news:uglqwGZmDH A.2536@tk2msftn gp13.phx.gbl...[color=green]
          > > Take a look at
          > > PageParser.GetC ompiledPageInst ance[/color]
          >
          > Brian, we should remind people that "This member supports the .NET Framework
          > infrastructure and is not intended to be used directly from your code.".
          >
          > Of course, I use it also, in the absence of any
          > "GetTheStandard HttpHandlerFor" method. Take a hint, Microsoft![/color]

          Comment

          Working...