March 08, 2004 12:03 AM

Tap the Pipeline

DevConnections
Rating: (0)

Back Draft

 

Tap the Pipeline

Powerful and useful HttpModules are just begging to be built.

 

 

When ASP.NET was released,third-party component vendors were quick to release new and powerful servercontrols that enabled functionality that was not easily available before, if atall. On the other hand, very few component vendors have released products thattap into the ASP.NET pipeline. That's a shame, because the pipeline is one ofthe most powerful aspects of ASP.NET.

 

The major building block upon whichthe ASP.NET pipeline is built is the HttpModule. By implementing theIHttpModule interface, you can obtain a reference to the currentHttpApplication object that is being executed when an ASP.NET page isrequested. Once you have that reference, the possibilities of what you can doare endless.

 

If your creative juices haven'tstarted flowing with ideas, let me share a few of mine with you. Like manypeople, my consulting practice keeps me so busy that I don't have enough timeto explore a lot of the product ideas that I have. Maybe some of you canbreathe some life into these HttpModule ideas, which would otherwise justgather dust in the corners of my cluttered brain.

 

URL Rewriting Engine

The canonical demo of anHttpHandler demonstrates how to Rewrite (aka "munge") URLs (http://www.15seconds.com/issue/030522.htm).The concept behind URL munging is that you can take a URL that would normallybe very complex (e.g. with a long directory structure and querystringparameters) and expose it to the world via a simple URL. When a request is madefor the simple URL, the URL Rewriting HttpModule intercepts it and re-directsit to the true URL. A good example of this concept is implemented by theTinyURL Web site (http://tinyurl.com).

 

Although there are several examplesof how to build a URL Rewriting HttpModule on the Web, nobody seems to havepackaged the concept into a commercial product. If you want URL Rewritingfunctionality, you have to roll it yourself. I'd like to see somebody build aflexible and robust URL Rewriting Engine that enables a rules-based approachand has a Web-based administration tool (perhaps using an HttpHandler likeTrace.axd).

 

Even though there is a lot offreeware source-code out there, I think that a good URL Rewriting Engine wouldsell well.

 

Image Servicing

The release of ASP.NET 2.0 willbring a new Image Service that will enable a lot of dynamic image generationfunctionality (which you will no doubt read about in upcoming issues of asp.netPRO). ASP.NET 2.0 is still in aholding pattern, though, and there is still a lot of room out there forspecialized image handlers. Say, for instance, that I run an online photographybusiness, and I want to offer hi-res preview pictures to my customers beforethey make a purchase. Obviously, I would want to watermark the images, so mycustomers can't just download the images and print them out themselves. Anideal solution would be to plug in an HttpHandler that would monitor access toimages in a particular directory. It would then inject a watermark into anyimages that were requested from that directory.

 

You might argue that an HttpHandler(which operates on user-configurable file extensions) could do the same thing -and you'd be right. Your choice of implementation would largely be dependent onwhether you wanted or needed access to the entire HttpApplication, or merelythe HttpContext of the current request. Besides watermarking, your imageservicing HttpModule could handle other image operations like cropping andthumbnailing.

 

Diagnostics

Diagnostics is by far my favoriteidea for an HttpModule. I have long been a student of debugging, and .NETexposes a great deal of debugging information to the developer andadministrator. Although ASP.NET tracing is adequate for raw applicationdebugging, it would be great to have a diagnostics HttpModule that I could pluginto the ASP.NET pipeline of my development and staging environments to help mediagnose tricky bugs.

 

What would really be helpful is ifthe HttpModule could parse and analyze application exceptions that are thrownand present me with links to the .NET Framework documentation or links tocommunity Web sites that deal with the problem I am facing. Of course, thetypical stack dump information should be available as well, but as anyone whohas spent some time developing ASP.NET applications will tell you, the standardexception handler page doesn't always give you much to go on.

 

The best part about a diagnosticsHttpModule is that you could merely rip it out of your machine.config orweb.config file before migrating it to production (I'd suggest machine.config,in order to prevent you from having to do this repeatedly).

 

These are just three ideas forpowerful and useful HttpModules that are just begging to be built (or refinedinto more viable commercial products). The possibilities are endless. Considerthis a formal request to third-party component developers to stem some of theflood of new server controls going to market (how many different charting,menu, tree, and grid controls do we really need?), and put some of theirefforts into building HttpModules that developers can snap into the pipeline oftheir ASP.NET applications. After two years, the HttpModule market is stillwide open. Throw your hat in the ring now.

 

Jonathan Goodyear is presidentof ASPSoft (http://www.aspsoft.com), anInternet consulting firm based in Orlando, Fla. He's a Microsoft CertifiedSolution Developer (MCSD) and author of Debugging ASP.NET (New Riders). Jonathanalso is a contributing editor for asp.netPRO. E-mail him at mailto:jon@aspsoft.comor through his angryCoder eZine at http://www.angryCoder.com.

 

 

 

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement




Comments from the DevConnections Community

Join our community of development pros.

Windows problem

I all, I have a problem on my Windows Vista that began afetr the purchase of an external Hard Disk Freecom. A few days afetr the purchase I discon...

Most Recent Posts

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS