Http Handler Question

J

Joe Spooner

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.CalsHandler,CalsHandler" />
</httpHandlers>

-----------------------------------------------
handler code is:
----------------
public void ProcessRequest(HttpContext context)
{
HttpResponse objResponse = context.Response;
HttpRequest objRequest = context.Request;
PageBuilder pgBuild = new PageBuilder();
objResponse.Write(pgBuild.Build(objRequest.PhysicalApplicationPath,
objRequest.PhysicalPath));
}
-----------------------------------------------

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

Cheers!
Joe
 
J

John Saunders

Brian W said:
Take a look at
PageParser.GetCompiledPageInstance

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
"GetTheStandardHttpHandlerFor" method. Take a hint, Microsoft!
 
J

Joe Spooner

John,

I agree with you totally. If I could implement something like
GetTheStandardHttpHandlerFor, 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.GetCompiledPageInstance. 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top