Eliminate .aspx File (100% dynamic page)

Discussion in 'ASP .Net' started by Frankie, Oct 9, 2007.

  1. Frankie

    Frankie Guest

    What would it take to send a page to a browser - and the HTML that comprises
    that "page" is 100% generated dynamically?

    Specifically, say I have all of the requisite HTML in a string variable. How
    do I push that string down to the browser?

    My situation is that I have a few .aspx pages containing very little
    boilerplate HTML markup and several placeholder controls. At runtime I am
    currently injecting the requisite HTML into the placeholder controls. I am
    wondering what it would take to eliminate the .aspx file altogether... such
    that when the browser requests, for example,
    www.DomainName\SomeFolder\File001.aspx I have logic that returns 100% of the
    HTML of "File001.aspx" with no such .aspx file having ever existed on disk
    on the Web server.



    Thanks.
     
    Frankie, Oct 9, 2007
    #1
    1. Advertising

  2. On Oct 9, 7:07 pm, "Frankie" <> wrote:
    > What would it take to send a page to a browser - and the HTML that comprises
    > that "page" is 100% generated dynamically?
    >
    > Specifically, say I have all of the requisite HTML in a string variable. How
    > do I push that string down to the browser?
    >
    > My situation is that I have a few .aspx pages containing very little
    > boilerplate HTML markup and several placeholder controls. At runtime I am
    > currently injecting the requisite HTML into the placeholder controls. I am
    > wondering what it would take to eliminate the .aspx file altogether... such
    > that when the browser requests, for example,www.DomainName\SomeFolder\File001.aspx I have logic that returns 100% of the
    > HTML of "File001.aspx" with no such .aspx file having ever existed on disk
    > on the Web server.
    >
    > Thanks.


    Do you know about URL Rewriting?
    http://www.google.com/search?hl=en&q=asp.net url rewriting
     
    Alexey Smirnov, Oct 9, 2007
    #2
    1. Advertising

  3. Frankie

    bruce barker Guest

    use an httpmodule instead of a page.

    -- bruce (sqlwork.com)

    Frankie wrote:
    > What would it take to send a page to a browser - and the HTML that comprises
    > that "page" is 100% generated dynamically?
    >
    > Specifically, say I have all of the requisite HTML in a string variable. How
    > do I push that string down to the browser?
    >
    > My situation is that I have a few .aspx pages containing very little
    > boilerplate HTML markup and several placeholder controls. At runtime I am
    > currently injecting the requisite HTML into the placeholder controls. I am
    > wondering what it would take to eliminate the .aspx file altogether... such
    > that when the browser requests, for example,
    > www.DomainName\SomeFolder\File001.aspx I have logic that returns 100% of the
    > HTML of "File001.aspx" with no such .aspx file having ever existed on disk
    > on the Web server.
    >
    >
    >
    > Thanks.
    >
    >
     
    bruce barker, Oct 9, 2007
    #3
  4. Frankie

    Frankie Guest

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Oct 9, 7:07 pm, "Frankie" <> wrote:
    >> What would it take to send a page to a browser - and the HTML that
    >> comprises
    >> that "page" is 100% generated dynamically?
    >>
    >> Specifically, say I have all of the requisite HTML in a string variable.
    >> How
    >> do I push that string down to the browser?
    >>
    >> My situation is that I have a few .aspx pages containing very little
    >> boilerplate HTML markup and several placeholder controls. At runtime I am
    >> currently injecting the requisite HTML into the placeholder controls. I
    >> am
    >> wondering what it would take to eliminate the .aspx file altogether...
    >> such
    >> that when the browser requests, for
    >> example,www.DomainName\SomeFolder\File001.aspx I have logic that returns
    >> 100% of the
    >> HTML of "File001.aspx" with no such .aspx file having ever existed on
    >> disk
    >> on the Web server.
    >>
    >> Thanks.

    >
    > Do you know about URL Rewriting?
    > http://www.google.com/search?hl=en&q=asp.net url rewriting



    Yes - but URL Rewriting has nothing to do with *how* a page is sent to the
    browser. It has to do with how pages are *identified.*
     
    Frankie, Oct 9, 2007
    #4
  5. On Oct 9, 7:50 pm, "Frankie" <> wrote:
    > "Alexey Smirnov" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > On Oct 9, 7:07 pm, "Frankie" <> wrote:
    > >> What would it take to send a page to a browser - and the HTML that
    > >> comprises
    > >> that "page" is 100% generated dynamically?

    >
    > >> Specifically, say I have all of the requisite HTML in a string variable.
    > >> How
    > >> do I push that string down to the browser?

    >
    > >> My situation is that I have a few .aspx pages containing very little
    > >> boilerplate HTML markup and several placeholder controls. At runtime I am
    > >> currently injecting the requisite HTML into the placeholder controls. I
    > >> am
    > >> wondering what it would take to eliminate the .aspx file altogether...
    > >> such
    > >> that when the browser requests, for
    > >> example,www.DomainName\SomeFolder\File001.aspx I have logic that returns
    > >> 100% of the
    > >> HTML of "File001.aspx" with no such .aspx file having ever existed on
    > >> disk
    > >> on the Web server.

    >
    > >> Thanks.

    >
    > > Do you know about URL Rewriting?
    > >http://www.google.com/search?hl=en&q=asp.net url rewriting

    >
    > Yes - but URL Rewriting has nothing to do with *how* a page is sent to the
    > browser. It has to do with how pages are *identified.*- Hide quoted text -
    >


    ASP.NET has to do it. Either something like Response.Write() or a
    custom HttpModule, as Bruce already suggested
     
    Alexey Smirnov, Oct 9, 2007
    #5
  6. You have to have an Http - addressable endpoint. It could be an ASPX page, or
    it could be an ASHX handler, etc. For a page, the only requirement is to have
    the
    <@Page declaration and specify the codebehind / codefile attribute. What you
    do in your code is completely up to you.
    -- Peter
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "Frankie" wrote:

    > What would it take to send a page to a browser - and the HTML that comprises
    > that "page" is 100% generated dynamically?
    >
    > Specifically, say I have all of the requisite HTML in a string variable. How
    > do I push that string down to the browser?
    >
    > My situation is that I have a few .aspx pages containing very little
    > boilerplate HTML markup and several placeholder controls. At runtime I am
    > currently injecting the requisite HTML into the placeholder controls. I am
    > wondering what it would take to eliminate the .aspx file altogether... such
    > that when the browser requests, for example,
    > www.DomainName\SomeFolder\File001.aspx I have logic that returns 100% of the
    > HTML of "File001.aspx" with no such .aspx file having ever existed on disk
    > on the Web server.
    >
    >
    >
    > Thanks.
    >
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Oct 9, 2007
    #6
  7. Add a file of type "generic handler". You can send back any kind of
    content you want by providing the correct HTTP header information via
    Response.Write statements. Code should look something like this:


    <%@ WebHandler Language="C#" Class="Handler" %>

    using System;
    using System.Web;

    public class Handler : IHttpHandler {

    Random r = new Random();

    public void ProcessRequest (HttpContext context) {

    String myParam = context.Request.Params.Get("clientkey");
    int numstrings = myProverbs.Length;
    int myRandIndex = r.Next(numstrings);
    String answer = myProverbs[myRandIndex];

    context.Response.ContentType = "text/xml";
    context.Response.AddHeader("Cache-Control", "no-cache");

    context.Response.Write("<?xml version=\"1.0\"?>");
    context.Response.Write("<stuff>");
    context.Response.Write("<quote>" + answer + "</quote>");
    context.Response.Write("<clientkey>" + myParam + "</
    clientkey>");
    context.Response.Write("</stuff>");
    }

    public bool IsReusable {
    get {
    return false;
    }
    }

    String[] myProverbs = {
    /* 0 */ "I am prepared for the worst, but hope for the best.
    (Benjamin Disraeli)",
    /* 1 */ "Lost time is never found again. (Ben Franklin)",
    /* 2 */ "History is a pack of lies about events that never happened
    told by people who weren't there. (George Santayana)",
    /* 3 */ "Tact is the ability to describe others as they see
    themselves. (Abe Lincoln)",
    /* 4 */ "Always remember, a cat looks down on man, a dog looks up to
    man, but a pig will look man right in the eye and see his equal.
    (Winston Churchill)",
    /* 5 */ "What's left at the bottom of the bag when it reaches you.
    (Definition of microchips)",
    };

    }

    On Oct 9, 4:31 pm, Peter Bromberg [C# MVP]
    <> wrote:
    > You have to have an Http - addressable endpoint. It could be an ASPX page, or
    > it could be an ASHX handler, etc. For a page, the only requirement is to have
    > the
    > <@Page declaration and specify the codebehind / codefile attribute. What you
    > do in your code is completely up to you.
    > -- Peter
    > Recursion: see Recursion
    > site: http://www.eggheadcafe.com
    > unBlog: http://petesbloggerama.blogspot.com
    > BlogMetaFinder: http://www.blogmetafinder.com
    >
    > "Frankie" wrote:
    > > What would it take to send a page to a browser - and the HTML that comprises
    > > that "page" is 100% generated dynamically?

    >
    > > Specifically, say I have all of the requisite HTML in a string variable. How
    > > do I push that string down to the browser?

    >
    > > My situation is that I have a few .aspx pages containing very little
    > > boilerplate HTML markup and several placeholder controls. At runtime I am
    > > currently injecting the requisite HTML into the placeholder controls. I am
    > > wondering what it would take to eliminate the .aspx file altogether... such
    > > that when the browser requests, for example,
    > >www.DomainName\SomeFolder\File001.aspx I have logic that returns 100% of the
    > > HTML of "File001.aspx" with no such .aspx file having ever existed on disk
    > > on the Web server.

    >
    > > Thanks.
     
    harborsparrow, Oct 12, 2007
    #7
    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. Andreas Klemt
    Replies:
    2
    Views:
    423
    Marina
    Jul 28, 2003
  2. Not4u
    Replies:
    9
    Views:
    1,056
    Not4u
    Feb 27, 2004
  3. Replies:
    8
    Views:
    6,710
    Neredbojias
    Dec 9, 2005
  4. fred
    Replies:
    3
    Views:
    291
    Zifud
    Mar 17, 2005
  5. Replies:
    5
    Views:
    904
Loading...

Share This Page