April 12, 2012

Inject Cool Stuff Into an HTML Head Tag with ASP.Net HttpModule

Have you ever wanted to inject some dynamic text into all of the ASP.NET Web Form pages in your site whether or not they use a master page?

 This sample project shows how to do just that: inject some dynamic text into all of the web page head tags in an ASP.NET Web Forms project.

It will work for pages that use master pages to generate their header and for pages that do not.

To accomplish this we create an ASP.Net HttpModule which takes advantage of the ASP.NET pipeline and runs our code to create the custom header information responding to the correct page life-cycle event.

More details to come...

April 9, 2012

Conditional Builder Design Pattern

Have you ever wanted to use the Builder design pattern to create a really cool fluent interface for building objects but you wanted to add conditions to the building? The good news is that you can do something like so:


Notice how in this contrived example a ninja only gets the "hide in shadows" skill after reaching 6th level? To handle a conditional builder take a look at the following code:

For a complete sample project check it out on my GitHub account!