Create Pages on the fly using IHttpHandler. Need advice

Discussion in 'ASP .Net' started by shapper, Nov 29, 2006.

  1. shapper

    shapper Guest

    Hello,

    In this moment I am creating all my aspx pages on my vb.code at
    runtime.

    It seems nonsense to have .aspx and .aspx.vb files in my projects.

    I am considering creating my pages on the fly using IHttpHandler.

    I already did that for delivering XML files.

    Could someone advice me on this?

    What are the ups and downs of doing this?

    Thanks,

    Miguel
    shapper, Nov 29, 2006
    #1
    1. Advertising

  2. shapper

    Karl Seguin Guest

    I don't fully understand what you're trying to do...It seems like whatever
    you are doing doesn't have an HTML/ASPX front-end component to it....

    aspx files are handled by a built-in handler, called the PageHandler...it's
    a relatively heavy process...it must raise a number of events (init, load,
    prerender, unload are the most well known) as well as do a lot of postback
    and viewstate manipulation.

    If your requests aren't doing any of those, such as a RSS feed, then a
    custom httphandler is typically the correct way to go. It's faster and it's
    the right tool for the job.

    On the flip side, you'll lose a lot of the framework laid out by the
    PageHandler (which is quite a bit)..it's typically pretty obvious if you
    need ASP.NET pages or not...

    Karl
    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > In this moment I am creating all my aspx pages on my vb.code at
    > runtime.
    >
    > It seems nonsense to have .aspx and .aspx.vb files in my projects.
    >
    > I am considering creating my pages on the fly using IHttpHandler.
    >
    > I already did that for delivering XML files.
    >
    > Could someone advice me on this?
    >
    > What are the ups and downs of doing this?
    >
    > Thanks,
    >
    > Miguel
    >
    Karl Seguin, Nov 29, 2006
    #2
    1. Advertising

  3. shapper

    shapper Guest

    Hi,

    Got it. I didn't know about the PageHandler part.

    I was just looking for a way to solve a problem which I am fighting for
    2 days:

    How to set the following Nested Master Pages at runtime:

    Parent.master
    | ---- Child.master
    | ------ Page.aspx

    Yes, I know that in Page.aspx.vb I can do Me.MasterPageFile =
    "~/_Child.master" on the PreInit event. However, I can't do the same on
    Child.master.vb because I don't have a PreInit event there.

    Do you know any article or have any code example which might help me
    with this?

    Thank You a Lot,
    Miguel

    Karl Seguin wrote:
    > I don't fully understand what you're trying to do...It seems like whatever
    > you are doing doesn't have an HTML/ASPX front-end component to it....
    >
    > aspx files are handled by a built-in handler, called the PageHandler...it's
    > a relatively heavy process...it must raise a number of events (init, load,
    > prerender, unload are the most well known) as well as do a lot of postback
    > and viewstate manipulation.
    >
    > If your requests aren't doing any of those, such as a RSS feed, then a
    > custom httphandler is typically the correct way to go. It's faster and it's
    > the right tool for the job.
    >
    > On the flip side, you'll lose a lot of the framework laid out by the
    > PageHandler (which is quite a bit)..it's typically pretty obvious if you
    > need ASP.NET pages or not...
    >
    > Karl
    > --
    > http://www.openmymind.net/
    > http://www.fuelindustries.com/
    >
    >
    > "shapper" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > In this moment I am creating all my aspx pages on my vb.code at
    > > runtime.
    > >
    > > It seems nonsense to have .aspx and .aspx.vb files in my projects.
    > >
    > > I am considering creating my pages on the fly using IHttpHandler.
    > >
    > > I already did that for delivering XML files.
    > >
    > > Could someone advice me on this?
    > >
    > > What are the ups and downs of doing this?
    > >
    > > Thanks,
    > >
    > > Miguel
    > >
    shapper, Nov 29, 2006
    #3
  4. shapper

    shapper Guest

    I was looking one of your articles in:

    http://codebetter.com/blogs/karlseguin/archive/2006/05/24/145397.aspx

    When you mean page model you are talking about events such as:

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
    EventArgs) Handles Me.PreInit
    ....
    End Sub

    Right? Is this what I would miss?

    In IHttpHandler I would need to do something like:

    AddHandler Label.Load, AddressOf Label_Load

    Is this what you mean?

    But would I need to do this for all events for all controls or only for
    the events where I need to place some code in?

    Using IHttpHandler to deliver the web pages have some advantages like
    getting rid of the .aspx pages and making the web site a little bit
    faster, right?
    Are there any documents about doing this?

    Just experimenting.

    Thanks,

    Miguel

    shapper wrote:
    > Hi,
    >
    > Got it. I didn't know about the PageHandler part.
    >
    > I was just looking for a way to solve a problem which I am fighting for
    > 2 days:
    >
    > How to set the following Nested Master Pages at runtime:
    >
    > Parent.master
    > | ---- Child.master
    > | ------ Page.aspx
    >
    > Yes, I know that in Page.aspx.vb I can do Me.MasterPageFile =
    > "~/_Child.master" on the PreInit event. However, I can't do the same on
    > Child.master.vb because I don't have a PreInit event there.
    >
    > Do you know any article or have any code example which might help me
    > with this?
    >
    > Thank You a Lot,
    > Miguel
    >
    > Karl Seguin wrote:
    > > I don't fully understand what you're trying to do...It seems like whatever
    > > you are doing doesn't have an HTML/ASPX front-end component to it....
    > >
    > > aspx files are handled by a built-in handler, called the PageHandler...it's
    > > a relatively heavy process...it must raise a number of events (init, load,
    > > prerender, unload are the most well known) as well as do a lot of postback
    > > and viewstate manipulation.
    > >
    > > If your requests aren't doing any of those, such as a RSS feed, then a
    > > custom httphandler is typically the correct way to go. It's faster and it's
    > > the right tool for the job.
    > >
    > > On the flip side, you'll lose a lot of the framework laid out by the
    > > PageHandler (which is quite a bit)..it's typically pretty obvious if you
    > > need ASP.NET pages or not...
    > >
    > > Karl
    > > --
    > > http://www.openmymind.net/
    > > http://www.fuelindustries.com/
    > >
    > >
    > > "shapper" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > In this moment I am creating all my aspx pages on my vb.code at
    > > > runtime.
    > > >
    > > > It seems nonsense to have .aspx and .aspx.vb files in my projects.
    > > >
    > > > I am considering creating my pages on the fly using IHttpHandler.
    > > >
    > > > I already did that for delivering XML files.
    > > >
    > > > Could someone advice me on this?
    > > >
    > > > What are the ups and downs of doing this?
    > > >
    > > > Thanks,
    > > >
    > > > Miguel
    > > >
    shapper, Nov 29, 2006
    #4
  5. shapper

    Karl Seguin Guest

    Yes, that's what I mean.

    If you have labels (or any controls) and master pages, then you don't want
    to use your own handler.

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "shapper" <> wrote in message
    news:...
    >I was looking one of your articles in:
    >
    > http://codebetter.com/blogs/karlseguin/archive/2006/05/24/145397.aspx
    >
    > When you mean page model you are talking about events such as:
    >
    > Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As
    > EventArgs) Handles Me.PreInit
    > ....
    > End Sub
    >
    > Right? Is this what I would miss?
    >
    > In IHttpHandler I would need to do something like:
    >
    > AddHandler Label.Load, AddressOf Label_Load
    >
    > Is this what you mean?
    >
    > But would I need to do this for all events for all controls or only for
    > the events where I need to place some code in?
    >
    > Using IHttpHandler to deliver the web pages have some advantages like
    > getting rid of the .aspx pages and making the web site a little bit
    > faster, right?
    > Are there any documents about doing this?
    >
    > Just experimenting.
    >
    > Thanks,
    >
    > Miguel
    >
    > shapper wrote:
    >> Hi,
    >>
    >> Got it. I didn't know about the PageHandler part.
    >>
    >> I was just looking for a way to solve a problem which I am fighting for
    >> 2 days:
    >>
    >> How to set the following Nested Master Pages at runtime:
    >>
    >> Parent.master
    >> | ---- Child.master
    >> | ------ Page.aspx
    >>
    >> Yes, I know that in Page.aspx.vb I can do Me.MasterPageFile =
    >> "~/_Child.master" on the PreInit event. However, I can't do the same on
    >> Child.master.vb because I don't have a PreInit event there.
    >>
    >> Do you know any article or have any code example which might help me
    >> with this?
    >>
    >> Thank You a Lot,
    >> Miguel
    >>
    >> Karl Seguin wrote:
    >> > I don't fully understand what you're trying to do...It seems like
    >> > whatever
    >> > you are doing doesn't have an HTML/ASPX front-end component to it....
    >> >
    >> > aspx files are handled by a built-in handler, called the
    >> > PageHandler...it's
    >> > a relatively heavy process...it must raise a number of events (init,
    >> > load,
    >> > prerender, unload are the most well known) as well as do a lot of
    >> > postback
    >> > and viewstate manipulation.
    >> >
    >> > If your requests aren't doing any of those, such as a RSS feed, then a
    >> > custom httphandler is typically the correct way to go. It's faster and
    >> > it's
    >> > the right tool for the job.
    >> >
    >> > On the flip side, you'll lose a lot of the framework laid out by the
    >> > PageHandler (which is quite a bit)..it's typically pretty obvious if
    >> > you
    >> > need ASP.NET pages or not...
    >> >
    >> > Karl
    >> > --
    >> > http://www.openmymind.net/
    >> > http://www.fuelindustries.com/
    >> >
    >> >
    >> > "shapper" <> wrote in message
    >> > news:...
    >> > > Hello,
    >> > >
    >> > > In this moment I am creating all my aspx pages on my vb.code at
    >> > > runtime.
    >> > >
    >> > > It seems nonsense to have .aspx and .aspx.vb files in my projects.
    >> > >
    >> > > I am considering creating my pages on the fly using IHttpHandler.
    >> > >
    >> > > I already did that for delivering XML files.
    >> > >
    >> > > Could someone advice me on this?
    >> > >
    >> > > What are the ups and downs of doing this?
    >> > >
    >> > > Thanks,
    >> > >
    >> > > Miguel
    >> > >

    >
    Karl Seguin, Nov 30, 2006
    #5
  6. shapper

    Karl Seguin Guest

    I was able to solve the problem by doing hooking into the constructor for
    Child.master...dunno if you'll have any side effects this way though...

    public sub Child()
    MasterPageFile = "Parent.master"
    end sub

    Pages, controls and masterpages are all class deep down...and if something
    fires BEFORE PreInit, the constructor must be it :)

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "shapper" <> wrote in message
    news:...
    > Hi,
    >
    > Got it. I didn't know about the PageHandler part.
    >
    > I was just looking for a way to solve a problem which I am fighting for
    > 2 days:
    >
    > How to set the following Nested Master Pages at runtime:
    >
    > Parent.master
    > | ---- Child.master
    > | ------ Page.aspx
    >
    > Yes, I know that in Page.aspx.vb I can do Me.MasterPageFile =
    > "~/_Child.master" on the PreInit event. However, I can't do the same on
    > Child.master.vb because I don't have a PreInit event there.
    >
    > Do you know any article or have any code example which might help me
    > with this?
    >
    > Thank You a Lot,
    > Miguel
    >
    > Karl Seguin wrote:
    >> I don't fully understand what you're trying to do...It seems like
    >> whatever
    >> you are doing doesn't have an HTML/ASPX front-end component to it....
    >>
    >> aspx files are handled by a built-in handler, called the
    >> PageHandler...it's
    >> a relatively heavy process...it must raise a number of events (init,
    >> load,
    >> prerender, unload are the most well known) as well as do a lot of
    >> postback
    >> and viewstate manipulation.
    >>
    >> If your requests aren't doing any of those, such as a RSS feed, then a
    >> custom httphandler is typically the correct way to go. It's faster and
    >> it's
    >> the right tool for the job.
    >>
    >> On the flip side, you'll lose a lot of the framework laid out by the
    >> PageHandler (which is quite a bit)..it's typically pretty obvious if you
    >> need ASP.NET pages or not...
    >>
    >> Karl
    >> --
    >> http://www.openmymind.net/
    >> http://www.fuelindustries.com/
    >>
    >>
    >> "shapper" <> wrote in message
    >> news:...
    >> > Hello,
    >> >
    >> > In this moment I am creating all my aspx pages on my vb.code at
    >> > runtime.
    >> >
    >> > It seems nonsense to have .aspx and .aspx.vb files in my projects.
    >> >
    >> > I am considering creating my pages on the fly using IHttpHandler.
    >> >
    >> > I already did that for delivering XML files.
    >> >
    >> > Could someone advice me on this?
    >> >
    >> > What are the ups and downs of doing this?
    >> >
    >> > Thanks,
    >> >
    >> > Miguel
    >> >

    >
    Karl Seguin, Nov 30, 2006
    #6
    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. lapin
    Replies:
    0
    Views:
    740
    lapin
    Nov 18, 2003
  2. lapin
    Replies:
    1
    Views:
    2,246
    Teemu Keiski
    Nov 19, 2003
  3. jchrisf79
    Replies:
    8
    Views:
    271
    Andrew Thompson
    Dec 16, 2007
  4. Brian

    Fly outmenu on the fly

    Brian, Apr 8, 2005, in forum: Javascript
    Replies:
    0
    Views:
    96
    Brian
    Apr 8, 2005
  5. Phil Powell

    I need to create a form on the fly

    Phil Powell, May 3, 2006, in forum: Javascript
    Replies:
    6
    Views:
    145
    Phil Powell
    May 4, 2006
Loading...

Share This Page