downloads, aspnet, net comments edit

I posted before about an ASP.NET 1.1 way to deploy in a close-to-binary-only format, embedding ASPX files as resources in your assemblies.  That way doesn’t work in .NET 2.0… but it turns out they added something better in .NET 2.0 that lets you create a more complete solution - System.Web.Hosting.VirtualPathProvider.

The basic idea is that rather than talk directly to the filesystem, ASP.NET provides a “hosting environment” and asks for files from there.  VirtualPathProviders can register and respond to these requests.  By default, ASP.NET has a file system based provider registered, so everything works out like it always did.  While you can’t virtualize everything (web.config, App_Code, and so forth all actually have to exist in the filesystem), other ASP.NET files (*.aspx, *.ascx) can exist in a virtual file store.

There’s a great article on MSDN about how to serve your site from a ZIP file, but I wanted to take it one step further and serve from embedded resources.  Enter Paraesthesia.Web.Hosting.EmbeddedResourcePathProvider.

This VirtualPathProvider implementation allows you to register assemblies that are allowed to serve embedded files and specify on those assemblies which embedded resources are allowed to be served.  After you register the provider (programmatically at app startup), when ASP.NET asks for a specific page it will ask the provider.  If the provider finds that file in embedded resources, it’s served from there; if not, it falls back to the filesystem as usual.

Detailed usage is included in the API documentation and an implementation can be seen in the included demo site.  On a high level, you need to:

  1. Set each page, control, or file in your web project that you wish to serve embedded as embedded resource.  (Normally these are “Content” files - switch to “Embedded Resource” in your project to embed them.)
  2. Add a Paraesthesia.Web.Hosting.EmbeddedResourceFileAttribute to your web project assembly for each embedded page.  This lets the VirtualPathProvider know which resources are allowed to be served (and allows you to differentiate files that get served from resources that are used for other purposes).
  3. In your Global.asax, at application startup, add a registration for the EmbeddedResourcePathProvider: HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourcePathProvider());
  4. In your web.config, add a configSection called embeddedFileAssemblies that gets parsed by Paraesthesia.Configuration.StringCollectionSectionHandler. This section will contain the list of assemblies that the VirtualPathProvider should query for EmbeddedResourceFileAttributes.
  5. Optionally specify the ability to override embedded files with files in the filesystem by adding an appSettings key called Paraesthesia.Web.Hosting.EmbeddedResourcePathProvider.AllowOverrides and setting it to “true”.

A demo web site with an installer is included to show the provider in action.  It will also help you see what the code/config/attribute declarations are so you can follow that pattern in your own usage.

This sort of thing, in combination with things like the WebResourceAttribute and WebResource.axd can get you ever closer to serving an entirely binary web site.


  • This won’t work for sites that rely on file system security. I primarily work with forms authentication, so this isn’t a problem for me. It may be for you.
  • Cache dependencies on embedded resource files are actually set on the assemblies that contain the files.
  • It doesn’t support “directories” so if you use the HostingEnvironment to go directory browsing, you won’t see the embedded files.
  • There’s some weirdness with IIS where you can’t set the “default page” for a directory to be an embedded file.  IIS detects it’s not there and pre-emptively returns a 404.
  • Your site has to run in High trust mode for this to work. This is a requirement of the VirtualPathProvider framework.
  • This is going to be a one-shot deal. I’m not going to be posting updates or actively supporting it or anything. Take it at your own risk, your mileage may vary, etc.
  • The source bundle includes the source for the VirtualPathProvider, related attributes, support classes, a readme, and a demo web site illustrating the project in action. The compiled bundle is the compiled assembly, the XML API doc, the installer for the demo site, and a readme.
  • It’s totally free and open-source. Do whatcha like.

Download EmbeddedResourcePathProvider Compiled Package

Download EmbeddedResourcePathProvider Source

Found this nifty little thing via Penny Arcade.  It’s a site where you draw a 2D character and they make it dance around in 3D using Flash.  I threw together this stick figure one to see how it works.  Sorta neat, and free.  But, damn, the music is annoying.

Note that I don’t think they thought about scalability on the thing and it’s become reasonably popular, so it seems to be hit or miss on whether the thing actually plays.

media, tv comments edit

Saw a preview for a new CBS show called Kid Nation last night.  The idea is that they set 40 kids up in an old west town with no adults around and see how they fare.

Anyone else think this sounds like Lord of the Flies, western style?  I’m waiting for the part where Piggy gets killed on national television.

Yeah, they’ll probably edit that out.

Greg posted some great video that one of the crewmembers, Cassie, took during the fireworks show we did this year.  It’s pretty cool.  About 1:15 into the video, it zooms down and you can see the line of mortar racks and four people standing a few yards back from where it’s all going off.  I’m standing in that group with a road flare on the end of a stick (not lit), waiting to ensure that everything goes off.  (If one of the shells doesn’t go off electronically, I get to light up the flare and run out and light it by hand.  Fortunately that didn’t happen.)

media, music comments edit

My Chemical Romance - The Black

I’m a little late to the game on this one, but I’ve really been enjoying The Black Parade album by My Chemical Romance.

I think it started out by playing Guitar Hero II - one of the songs in there is “Dead!” which is from this album.  Jenn and I got 100% on that song (on “Easy” level) playing cooperative and it kind of stuck in my head.  I’d heard “The Black Parade” on the radio and liked it, so I figured I’d give it a run.

The album actually reminds me a bit of Pink Floyd’s The Wall - it plays out like a story, with the music style changing with each song, and in many cases becoming very… theatrical.  “Dead!” and “The Black Parade” are my favorite songs on the album, but the whole album is generally pretty darn good and is a very easy listen from front to back without having to skip any of the songs.

I can’t say I’ve heard much anything else by My Chemical Romance, but it does make me curious to hear more.  Maybe I’ll have to pick up something else by them and see how it fares.  Regardless, this thing rocks, and I totally recommend it.