Monday, June 25, 2012

Event Loop Architecture in IIS with C# and ASP.Net

Big Changes

I made a few breaking changes to my event loop architecture... but it's alpha, and AFAIK, I'm the only one using it, so whatever. However these changes were to accommodate the new asynchronous HttpHandler I added to handle sending web requests into the event loop via IIS!

The downside to all of this, is like everything with IIS, it requires a bit more setup than I'd like. To get started with using the new ALE HttpHandler, here's a few steps:

Getting Started With ALE in IIS

  1. Start a new Web Project. You can go ahead and gut the project leaving only the Web.Config and the Global.asax.
  2. Remove cruft from the Web.Config and register the AleHttpHandler.
    <?xml version="1.0"?>
          <compilation debug="true" targetFramework="4.0" />
           <validation validateIntegratedModeConfiguration="false"/>
           <modules runAllManagedModulesForAllRequests="true"/>
              <add verb="*" path="*"
  3. Add initialization code to Application_Start in the Global.asax.
    void Application_Start(object sender, EventArgs e)
        // Start the event loop.
        // Get the ALE server instance and wire up your middlware.
           .Use((req, res) => res.Write("Hello World"))
           .Use((req, res) => res.Write("<br/>No really."));
  4. Add tear down code to Application_End in the Global.asax.
    void Application_End(object sender, EventArgs e)
        // Shut down the event loop.
  5. Have fun.
This has been such a fun project. I am really thankful for all of the feedback and support I've received from my friends and others both on and offline.

No comments:

Post a Comment

This form allows some basic HTML. It will only create links if you wrap the URL in an anchor tag (Sorry, it's the Blogger default)