Get Started!

Custom Header Stamp - X-Hello: World

The equivalent Hello, World example for HTTP Modules, stamp the headers of every request.

So here's the go-to "Hello, World" example when using HTTP Modules.

Every request will have a custom HTTP Header :

X-Hello: World

using Net4orce.__HTTP_Handlers__;

namespace Example
{
  public static partial class ExampleApp 
  {
    static ExampleApp(){
      registerModules();
    }

    private static void registerModules(){

      DynAssDelegateModule.RegisterAction(

        // Key / Ident for Module
        @"custom-header-stamp",

        // The main thread for the module
        (httpApp) => {

          // Add a custom Header
          httpApp.Context.Response.Headers.Add(
            @"X-Hello",
            @"World"
          );
        }
      );

    }
  }
}

This will produce :

Custom Headers in Dev Tools

Notice how the call to the method is within the init of the applicaiton object, you'll need to reference the app from somewhere like your default page when the app starts to register this module.