Scott on Writing

Musings on technical writing...

REQUEST: Ideas for a Useful HTTP Handler Demo?

I'm starting work on an article on dynamically generating content using HTTP handlers.  Naturally, I'll cover what HTTP handlers are and how they can be created, configured, and deployed.  I'd like to wrap up the article with a look at some HTTP handler demos.  The cannonical one is to create an HTTP handler to work with images somehow, such as watermarking the image, dynamically thumbnailing the image, or resizing the image on the fly.  I plan on a quick demo of watermarking and protecting your images against bandwidth thiefs (namely, making sure that someone doesn't directly link to your images on your Web site from their site), but am interested if the handful of people who actually read my blog might have any ideas/suggestions on a second HTTP handler demo.

My current idea is kind of a contrived one, since it would not make sense to do this at runtime, but... it's an HTTP handler for compressing external JavaScript files.  Namely, the HTTP handler is attached to files with the .js extension.  Requests that come in for .js files, then, are compressed, removing superlfuous whitespace, comments, etc.  (Thanks to regex guru Darren Neimke for some pointers on stripping whitespace effectively.)

If any of y'all have suggestions for other HTTP handler demos that might be more interesting / plausible in a real-world setting, I'd be interested to hear them...

Thanks.

posted on Wednesday, March 24, 2004 1:22 PM

Feedback

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/24/2004 1:38 PM Jake

NOT MY IDEA.. But I saw an HTTP handler that "pretty printed" code. Leave a *.cs file in your directory and when a user requests it through an HTTP request, it will make it all neat and spiffy with HTML and copy/paste friendly output.

Jake

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/24/2004 1:48 PM Scott Mitchell

Jake, that is a cool idea! Where did you read about it?

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/24/2004 2:20 PM AC

I love the idea of watermarking the images if they are in a specific directory (like a photoalbum). Maybe something that also would show you a thumbnail list of all the images based off your request... something like the request of http://foo.com/album/2004/01/20.til would show thumbnail image list (.til) of 20 thumbnails per page (20.til) for Jan-2004?

# Demo Sharepoint 3/24/2004 3:50 PM Steve Ellis

Check out SPS 2003 and how it makes uses of custom handlers to generate dynamic html content that is loaded from its content database (or CMS). It's an excellent example of how HTTP handlers can be used to write complex web-based systems.

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/24/2004 8:07 PM Jalil Vaidya

I don't know how big (or small) you want your demo to be but I think an example of something like IBuySpy portal or such framework at smaller scale would be very interesting. A lot of information is available about how to write simple handlers but there is very little available about how to write Handler based DLL only (i.e. no .aspx pages if possible) entriprise applications. May be you can write a series of articles throwing more light on this form of ASP.NET application development ;-)

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/24/2004 11:42 PM Nasseam Elkarra

I can't remember where I saw it on the web, but there was mention of a CSS Handler that allowed for putting variables into CSS files. Any familiar with CSS will tell you that it is pain sometimes not being able to define global variables which can be used throughout your CSS file. The idea for the handler would be to create some syntax for defining variables, have the handler convert the variables and the rest of the document into standard css, and return the result.

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/25/2004 1:07 AM Paul Bartlett

Might not be of much general use, but I've recently used handlers to make auto-generated (NDoc or Doxygen) documentation look like an external wiki for FlexWiki to link to (see http://blogs.geekdojo.net/pdbartlett/archive/2004/03/12/1370.aspx), but I guess this is really just URL rewriting rather than a full-blown handler example...

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/25/2004 1:09 AM Paul Bartlett

The CSS variables handler was Rory's (http://neopoleon.com/blog/posts/4069.aspx) and he's actually a little worried about the lack of feedback (http://neopoleon.com/blog/posts/4702.aspx ;)

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/25/2004 5:33 AM Justin Lovell

What about doing the following Scott:

HttpHandler to get internal resources from assemblies (pretty much what Whidbey apparently has).

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 3/25/2004 11:51 AM Terry Denham

This may be a too large of a topic but I was interested in writing a WebDAV/DeltaV http handler ( more as an exercise than anything else). This could be not just for WebDAV/DeltaV but for any HTTP extension protocol. Not a full implementation but a here's how you get started.

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 4/1/2004 2:35 PM SSL Redirector

Redirect to/from SSL

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 4/27/2004 6:16 PM Vick

How about producing "Clean URLs" ?
I mean no "?" or "&" in the url.
Good for search engines.

# Serving Dynamic Content with HTTP Handlers 5/3/2004 5:30 PM Scott on Writing

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/4/2004 4:06 PM kiran

I could not find source code with the article!

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/4/2004 4:26 PM Scott Mitchell

kiran, I contacted my MSDN editor and he's getting a link to the code added to the article.

Thanks for the heads up...

# HTTP Handlers For Trackbacks 5/6/2004 1:21 PM Kingsley Tagbo

HTTP Handlers for trackbacks to web sites other than blogs.

# Implementing PingBacks and TrackBacks with HTTP Handlers 5/6/2004 7:05 PM Kingsley Tagbo

Httphandlers can be used to add Pingback and Trackback capability to web sites that are not necessarily blogs.

# Http Handler to Obfuscate/Shrink Javascript 5/10/2004 1:48 PM Ed Meyers

People run their javascript through obfuscation to shrink the size and make it harder to understand. Would be great for a handler to do so you could keep nice javascript checked in with the source code. I'd just like it because I put a lot of comment blocks in my Javascript to keep it understandable and maintainable. But, I don't like to send down 20K worth of /********************************'s.

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/13/2004 4:18 AM Claes R

In a solution that has both asp and aspx pages
i would like to have all page requests both asp and aspx pass thru a handler/module and have that handler/module decide if the pageurl is on a closed list. If so redirect request to info page.

=> A module/handler that can show "sub system closed" for both asp and aspx pages.

The tricky part is that asp requests has to be redirected/passed to asp process some how (i assume)

Doable ??


/Claes R.

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/13/2004 1:52 PM Cato Antonsen

What about serving several domains? Usefull when you are renting one webhotel which several domains are pointing to.

For example the user requests www.domain_a.com/somefile.aspx but the user is redirected to www.mydomain.com/domain_a/somefile.asp or www.domain_b.com/dir/someotherfile.aspx which is redirected to www.mydomain.com/domain_b/dir/someotherfile.aspx

Off course the user should only see her original address.

Possible?

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/13/2004 2:12 PM Scott Mitchell

Cato, that technique is referred to as URL Rewriting, and can be accomplished with either an HTTP handler or an HTTP module. In fact, I have an entire article written about URL Rewriting: http://msdn.microsoft.com/asp.net/using/building/web/default.aspx?pull=/library/en-us/dnaspp/html/urlrewriting.asp

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/13/2004 3:58 PM Tony Gorman

I have read most of the URL Rewriting articles, including yours and they all fall short in one area. Namely the fact that the rewriting information is stored in web.config.

I work on a site where we serve content from a link such as www.mysite.com/story.aspx?id=123

for lots of these, we have set up directories and dropped a server.transfer into the default doc in the folder, pointing to the story.aspx url.

EG www.mysite.com/design/ points at www.mysite.com/story.aspx?id=123

What I would like would be a simple system that allows users to create both a folder alias and the destination url and store this, without a developer being involved.

The web.config /http handler approach is fine if you only have a few redirects. However, I doubt it would scale well. We currently have 200 redirects.

Another issue would be the fact that editing web.config forces an application restart.

Could the HTTP handler approach read its data in from a hashtable instead? Users could write their redirect data to a sql table or xml file, and this could be read in by the redirector...

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/13/2004 9:36 PM Scott Mitchell

************************************
Could the HTTP handler approach read its data in from a hashtable instead?
************************************

Most definitely. This, as you noted, would have several advantages over using Web.config.

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/15/2004 2:19 AM Arjun Bahree "The Drunk Coder"

I think we can have an HTTPHandler for receiving requests with an extension of .SQL and then making those files go to a SQL Forwarder application program that takes the file from the servers prebuilt SQL files, executes them (or if precompiled as sprocs) and sends a nicely formatted report to the IIS....How abt thsi scott?

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/17/2004 9:54 AM Marian VETEANU

I implemented a useful HTTP Handler for my company. I'll not give you more details about the implementation, instead I'll chose an abstract scenario.

Lets say you have a proprietary application scripting language. This is used to customize a GUI application. You want to be allow users to develop web applications using the same scripting language. With an HTTP handler you can assign an arbitrary extension, let's say .lims and when a browser makes a request to a .lims document the HTTP handler intercepts the request, passes to your proprietary applicaiton which will do the processing and return an HTML response. The http handler writes the response to the response stream.

Basicaly, with the HTTP handler technology, I succeded in an easy way to develop an ASP like platform for our proprietary scripting language.

Other applicabilities includes the possibility to make web applications in basicaly any scripting language that has a command line interpreter. The HTTP handler will invoke automaticaly the command line interpretter passing inside the script the HTTPContext. The script will just generate HTML as response..

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 5/23/2004 3:46 AM gary

.NET proper Server push handler would be nice

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 8/28/2004 5:18 PM URL Clean UP

Use the HTTP Handler to service requests for the Child Portals and WorkSpaces of a Portal Server 2003 Server Farm so that end users can type
"Http://portal/HR/Forms"
instead of
"Http://portal010/C1A/HRA01/00_Forms".

# re: REQUEST: Ideas for a Useful HTTP Handler Demo? 11/3/2004 9:30 AM Leonardo Nascimento

I'd trying to build up a HandlerFactory-based navigation system.

User navigates through a menu and select a use-case realization. The factory then selects the class which makes all the processing for the request in that use case using reflection (this class also needs to identify in which step of the use case you are in), adds a dataset with all the data needed to be presented and redirects to the right page for visualization.

I think this could be a great example if you can keep it a bit more simple than the Front controller implementation made by MS.

The Handler would come for *.UseCase and the step could be identified by a number after the question mark.

What do you think?

# Contenu dynamque via un HTTPhandler : des id 4/16/2005 3:40 PM The Mit's Blog

# Contenu dynamque via un HTTPhandler : des id 4/17/2005 10:26 AM The Mit's Blog

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<July 2008>
SMTWTFS
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Comment Stats

DayTotal% of Total
Sunday 1896.8%
Monday 39014.0%
Tuesday 46916.8%
Wednesday 51518.5%
Thursday 54419.5%
Friday 50818.2%
Saturday 1706.1%
Total 2785100.0%

Hour1Total% of Total
12:00 AM 682.4%
1:00 AM 712.5%
2:00 AM 632.3%
3:00 AM 752.7%
4:00 AM 572.0%
5:00 AM 1093.9%
6:00 AM 1114.0%
7:00 AM 1615.8%
8:00 AM 1756.3%
9:00 AM 1505.4%
10:00 AM 1736.2%
11:00 AM 1826.5%
12:00 PM 1906.8%
1:00 PM 1766.3%
2:00 PM 1605.7%
3:00 PM 1324.7%
4:00 PM 1124.0%
5:00 PM 983.5%
6:00 PM 913.3%
7:00 PM 993.6%
8:00 PM 853.1%
9:00 PM 802.9%
10:00 PM 833.0%
11:00 PM 843.0%
Total 2785100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.14144
Monday 5.35353
Tuesday 4.35444
Wednesday 7.58644
Thursday 6.87625
Friday 5.45414
Saturday 5.03161
Total 5.802785

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.45109
9:00 AM 6.34279
10:00 AM 6.41250
11:00 AM 4.28184
12:00 PM 6.98342
1:00 PM 2.87112
2:00 PM 5.29222
3:00 PM 8.54299
4:00 PM 3.9190
5:00 PM 5.78156
6:00 PM 4.52113
7:00 PM 9.32177
8:00 PM 9.06154
9:00 PM 5.14113
10:00 PM 6.2381
11:00 PM 4.5732
Total 5.802785

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles