[Mono-devel-list] Custom handlers for mod_mono

Joshua Tauberer tauberer at for.net
Sat Jan 22 08:23:13 EST 2005


Anthony,

Anthony Gorecki wrote:
> I recently encountered http://www.govtrack.us and read the article
> regarding custom request handlers for mod_mono, bypassing ASP.NET.

For others reading, this is:
   http://www.govtrack.us/articles/20041003.xpd
And you may not have seen that I created a page (after the article) with
the source and .NET binary for my page generation system:
   http://taubz.for.net/code/xpd/

I think describing it as bypassing ASP.NET makes it seem more low-level
than it is.  The custom http handler works through ASP.NET and the
System.Web assembly, through XSP (that is, the mod_mono counterpart of
XSP).  It just overrides the usual mechanism for generating the actual
page content.

> Would it therefore be possible to completely bypass all script-based
> processing?

There is no scripting involved in the GovTrack pipeline, unless you
mean XSLT.  From what you wrote later in your email, I think you might
have the wrong impression about how Mono, C#, ASP.NET, and XPD work.

The custom http handler that XPD uses is written in C#, but it is
compiled into a binary .NET assembly.  That assembly is executed by
Mono, which compiles it at runtime into native machine code (via JIT).

ASP.NET is likewise a compiled .NET binary, providing core
infrastructure for web development (getting requests, sending responses,
cookies, etc.)  It doesn't involve scripting.

mod_mono + XSP (mod_mono_server) provide a link between Apache and the
.NET assemblies.  mod_mono plugs into Apache to handle requests, and it
passes off the requests to XSP, which in turn loads the needed 
assemblies and passes off the requests to ASP.NET and the custom http 
handler.

So, implementing a custom http handler for ASP.NET, exactly as I 
described in the article, involves no scripting.  It happens that 
GovTrack relies heavily on XSLT (which isn't usually called scripting 
anyway), but that's just a detail.

> I would presume that it would be possible to place that block of code
> into a file, and then have the file managed by a custom request
> handler.

This is exactly what XPD does.  It loads an XML file and carries out
further processing according to what's in the file.  In GovTrack, it 
happens to invoke XSLT, but you could be invoking other .NET routines to 
do anything.

> I would (ideally) prefer not to have XSP installed on the servers 
> that would be running a  content management system on the custom
 > handlers. Is there a way to run the custom handlers _without_ XSP?

That's like saying is there a way to run Microsoft Office without 
Microsoft Windows.  Mono and XSP are the platform on which the custom 
handlers are run.  In fact, that's all XSP does (with mod_mono) -- it 
takes requests from Apache and invokes a handler in .NET.

I'm presuming that by 'custom handlers' you mean a handler written in a 
.NET language and run by Mono.  If you mean you want to write a custom 
handler in C, then you want to write an Apache plugin, and you could use 
mod_mono as an example (although there may be simpler examples elsewhere 
on the web.)

The moral of this story is that what you are trying to do is probably 
exactly what custom http handlers already are.  (It's a happy ending.)

-- 
- Joshua Tauberer

http://taubz.for.net

** Nothing Unreal Exists **





More information about the Mono-devel-list mailing list