In BlogEngine.NET, all files and images that are inserted on a post will be served using an HttpHandler. Actually, they are served by FileHandler and ImageHandler respectively. They are almost identically and they both share the same event model. For the purpose of this example, I’ll stick with the file handler but the examples will work for both.

Events

There are three events on the file handler.

  • BeforeServing
  • FileServing
  • BadRequest

BeforeServing
This event is fired before a file is served, no matter if it exists on disk or not.

FileServing
This event is fired when the file exists on disk and the handler is serving it to the requesting client.

BadRequest
This event is fired when the requested file does not exist on disk and therefore cannot be served.

Uses

The events are not used anywhere by BlogEngine.NET. They are there for plug-ins to take advantage of. It would be quite easy to build an HttpModule that listens to the FileServing event and logs the request for statistical purposes. Another module could listen to BeforeServing, so it could stop the request if it comes from another website. That way you can prevent deep links to your files. The BadRequest event can be used to log non-existing files so you can fix broken links.

This is just some of the possibilities that the FileHandler's events can be used for.

The difference between the ImageHandler and FileHandler has something to do with client-side caching and content-types. Other than that they are alike.

After a lot of hard work I am very please to present the BlogEngine.NET for anyone to download and use. The blog engine is for anyone, but designed specifically to .NET developers that like to push software further than intended.

BlogEngine.NET may be the simplest and most light weight ASP.NET blog at the moment, but still full featured. Here are some of the features:

  1. Multi-author support
  2. Pingbacks and trackbacks
  3. Event based for plug-in writers
  4. Theming directly in master pages and user controls
  5. Gravatar and coComments implemented
  6. Live preview on commenting
  7. Full editing and creation of pages that are not posts
  8. Extended search capabilities
  9. Tag cloud
  10. Self updating blogroll
  11. Runs entirely on XML. No database needed

To get stated using the BlogEngine.NET, go to the website – a website built on the engine.