Eliminate .aspx File (100% dynamic page)

  • Thread starter Thread starter Frankie
  • Start date Start date
F

Frankie

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.
 
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
 
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)",
};

}
 
Back
Top