Use IHttpHandler not ASPX for pro web apps

J

John Rivers

ASPX which means ASPX pages, the code-behind concept, User Controls,
Web Controls etc. is very poorly designed and makes it extremely hard
to develop professional quality web applications.

ASPX is Microsoft's attempt to "dumb down" web application development
to help unskilled developers such as web design agencies achieve some
results.

For high quality applications IHttpHandlers are the way to go.

To keep a line between the design and the function you can include some
XSLT in the output path.

Now the developer need only output the structural elements of the web
app - forms, form fields, submit buttons, hyperlinks and data
structures in XML-compatible HTML.

Each IHttpHandler will have an associated XSLT, for example:

http://server/path/script.aspx (this is mapped to httphandler)
which processes /path/script.xslt as the final step before output

The XslTransform can callback into the developer using a callback
object and namespace.

Now it is easy to do the following:

- create mostly self generating applications freeing you from the
manual labour that ASPX demands
- redirect after (attempted) state change requests
- form submit with location.replace

You can also include an output validater that logs warnings of invalid
html output.

This approach also makes it quite simple to target your output to XHTML
or HTML4.0 etc.

Shame on the team at Microsoft reponsible for architecting ASPX.
What a load of rubbish.

And I feel sorry for people learning ASPX who haven't yet realised how
bad it is.
They have made the mistake of thinking that whatever comes from
Microsoft must be good.
Not alway true.
 
J

Juan T. Llibre

I have a question for you regarding the subject of your post :
"Use IHttpHandler not ASPX for pro web apps"

If you intend to use IHttpHandlers for a web app,
exactly how are you going to do that without an ASPX page ?

After all, IHttpHandler is an interface in system.web: System.Web.IHTTPHandler,
and system.web is accessible from ASPX pages so, what are you going to use
to go back and forth between the client and the .Net Framework classes ?

Bottom line : if you're going to use System.Web.IHTTPHandler, you have to use ASPX.

You *cannot* use IHttpHandler and not use ASPX.

re:
Now it is easy to do the following:
- create mostly self generating applications freeing you from the
manual labour that ASPX demands

Could you post example code ?




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
J

John Rivers

You are mistaken.

ASPX *is* an HttpHandler.

How can you be an ASP.NET MVP and not know that?

Quote:

For example, ASP.NET maps all requests for .aspx files to the
PageHandlerFactory class in the global machine.config file:

<httphandlers>
...
<add verb="*" path="*.aspx"
type="System.Web.UI.PageHandlerFactory,System.Web" />
...
</httphandlers>

Ha ha ha ha ha

Why not spend more time studying and waste less time talking rubbish.
 
J

Juan T. Llibre

And that answers the question, how ?

From that same page :

---000---

An HTTP handler is a class that is responsible for rendering a particular resource,
or a particular type of resource.

In fact, each time you add an ASP.NET Web page to your project,
you are essentially writing a HTTP handler.

This is because when the HTML portion of an ASP.NET Web page gets
dynamically compiled at run time, it directly or indirectly inherits from
System.Web.UI.Page, which happens to be a HTTP handler implementation.

---000---

So, while ASPX is just an acronym for Active Server Pages eXtension,
it is only one of *many*, or *any* web extensions which can be used as a
container for ASPX functionality.

In other words, it's the *default* extension for System.Web.UI.Page,
which *is* the HttpHandler, not ASPX.

Your pointing me to this resource, written by Scott Mitchell, shows that you
misunderstood the question completely and don't understand what an httphandler
is, like your friend John doesn't understand it either.

Every single programmer in the world must have written a "vanity" extension.

I wrote an httphandler for the extension .juan , almost 10 years ago when ASP came out,
and did it again when ASPX came out, primarily because the methods to allow full
functionality changed between ASP and ASP.NET.

It's quite easy...and it's an example of an httphandler which allows a page container, like .juan,
different than a page with an aspx extension, to process instructions which will be processed by
the aspnet_isapi module, in order to render markup for whichever browser calls the page.

This isn't rocket science; it's just basic semantic definitions.

Continuing to quote from Scott's article :

The code-behind class for an ASP.NET Web page is an HTTP handler, knowing how to
render the markup for the particular Web page. It helps to think about handlers as specialized
renderers that know how to create the markup for a particular type of resource.

HTH...




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
J

Juan T. Llibre

re:
with no .aspx/.html/.asp

Really ? You must be confused.

What is the container which, when called, triggers ELMAH ?
Let me help you : it's an aspx page getting called by a browser.

ELMAH is composed of 3 subsystems :

1. An error logging subsystem
2. An HTTP module subsystem
3. An HTTP handler subsystem

Sure, ELMAH uses an HTTP handler subsystem, but that is *conveyed* through ASPX.

The HTTP handler subsystem provides a means for the error log to be rendered into markup,
or rendered as an error report delivered via email, making ELMAH a Web-based interface
to the error log, as well as an RSS feed.

That web-based interface *is* an ASPX page, which is the *default* extension
for System.Web.UI.Page, which *is* the HttpHandler, not ASPX.

So ELMAH, as a web-based interface to ASP.NET's error module,
must use "aspx" to do its job. It could do it without the aspx extension,
but then it would need some other extension which serves as a container
for instructions to be delivered to the ASP.NET engine ( aspnet_isapi.dll )
and to the IIS worker process.

In fact, ELMAH *does* use aspx.

The following HttpHandler web.config entry specifies that any incoming requests to
elmah's subdirectory and default page ( /elmah/default.aspx )
are be rendered by the ErrorLogPageFactory class configured in the ASP.NET
application's web.config:

<httpHandlers>
<add
verb="POST,GET,HEAD"
path="elmah/default.aspx"
type="GotDotNet.Elmah.ErrorLogPageFactory,
GotDotNet.Elmah, Version=1.0.5527.0, Culture=neutral,
PublicKeyToken
</httpHandlers>

So, before sending a link to an article, please make sure you have understood it.
It really would save everybody's time here.




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
K

Kevin Spencer

Hi Juan,

Just a clarification here:
Every single programmer in the world must have written a "vanity"
extension.

I wrote an httphandler for the extension .juan , almost 10 years ago when
ASP came out,
and did it again when ASPX came out, primarily because the methods to
allow full
functionality changed between ASP and ASP.NET.

"Vanity" extensions are not the only use for custom HttpHandlers. For
example, I recently had a requirement to return a text-only version of a
report which is generated from XML using XSLT. Since IE and some other
browsers ignore the "text/plain" content-type header, you can't return a
page with a .aspx extension as plain text. So I wrote an HttpHandler that
handles requests for ".txt" extensions.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 
J

Juan T. Llibre

re:
"Vanity" extensions are not the only use for custom HttpHandlers.

Of course not. I was just presenting an example. One of many possibilities.
Thanks for clarifying this.

The example you present is spot-on.

It's hard to educate kids with an attitude, isn't it ?

;-)




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
C

Christopher Reed

When I first "discovered" HttpHandlers, I played around with a DLL that
implemented IHttpHandler. Without creating an actual file, I was able to
map a specific file name that passed through my handler that created a
simple HTML page that was rendered in my browser. No physical file existed.
It is possible.

However, for the most part, creating pages through HttpHandlers only is not
very efficient and I rebuke the original poster's claim that ASPX files are
not the way to go. Yes, a person needs to understand programming to be
efficient, but no, just because one uses the ASPX/code-behind approach does
not make them "dumb-downed". Personally, if I had all of the time in the
world, I'd program everything in a text editor (okay, I do that for 1.x
apps) and put everything in DLLs using HttpHandlers. I'd probably even go
as far as programming in IL so I know that it's right with the CLR and not
fool around with the inefficient languages of C#, VB, C++, etc. Then, I
don't have all of the time in the world, so I need to use the tools and
libraries as efficiently as possible. As for the original poster, if going
the handler route best for him, so be it. But his assertions are opinions
and not fact. To each his own....
 
K

Kevin Spencer

It's hard to educate kids with an attitude, isn't it ?

It's frustrating, because you want to help them avoid the pitfalls you
discovered along the way. There are 2 ways to learn. You can learn by
experience, or you can learn by listening to those who already have it. The
second way is much easier than the first, but both work!

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 
G

gerry

whatever - you are clearly equating the asp.net pipeline with aspx - given
that definition then you are correct
although the op's intent was to generate content without the use of physical
..aspx pages which clearly is possible.
 
J

Juan T. Llibre

Yeah, sure.

I'll give the op the benefit of the doubt.

I asked for some sample code...but I don't see his post with it.
( perhaps a really simple proof-of-concept sample ? )

I wonder if what he argued was only hot air,
or whether he can put his money where his mouth is.




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
G

gerry

just for my own edification - can you point me to an official MS document
that refers to ASP.NET as "ASPX" ?

how does the example I referred to not count as sample code" ?
 
J

Juan T. Llibre

re:
just for my own edification - can you point me to an official
MS document that refers to ASP.NET as "ASPX" ?

I see you persist in deepening your misunderstanding.
Can you point to where I called ASP.NET "ASPX" ?

I explained that aspx is only a web extension, just like .html, .cfm or .juan.

re:
how does the example I referred to not count as sample code ?

It is "sample code", butnot sample code which doesn't use ASPX,
which is what the op claimed should be done.

Re-read the subject line and it should be quite evident :

"Use IHttpHandler not ASPX for pro web apps."

I'd like to see sample code which does *not* use ASPX.
I don't think it's possible.

If the sample doesn't use aspx, which is only the default web extension
for ASP.NET, it has to use a substitute web extension with identical functionality.

IHttpHandler does not function in a vacuum.
It's only an *interface* between ASP.NET and the client.

Why is this so difficult to grasp for you ?




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
G

gerry

my last post for this thread

the default asp.net handler for .aspx requests is a specific instance of an
http handler.
aspx cannot be implemented without using an http handler
an http handler can be implemented without using aspx ( the default .aspx
handler )
unless of course your definition of aspx is asp.net itself
 
J

Juan T. Llibre

You seeem to be going around in circles but,
as long as that's your last post on this thread,
this can be the last post on this thread for me, too.




Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
S

S. Justin Gengo [MCP]

Hmmmm,

I'm almost sorry this discussion is over it's very entertaining.

Juan, you should stop doing this:

*moves outstreched hand up and down*

and do this instead:

*moves outsrteched hand left and right*

Then everyone will understand.

:)

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
K

Kevin Spencer

I just have one question: Is it better to crack the big end or the little
end of the egg when you break it?

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 

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

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top