HttpRequest Recorder
Overview

Sometimes your webapplication on production systems suffers from strange errors that are irreproducible in a constrolled development environment. For example some of your code may forget to close a Stream object - some hours later your application breaks down with OutOfMemoryExceptions.

This is were HttpRequest recorder comes into play. By plugging the recorder into your webapplication, it records all requests to your application and saves them to a path of your choice. This recorded request information can be "replayed" using PlayerConsole later in a controlled environment - to hopefully enable you analyzing the problem down to the cause of your errors.

Of course usage is not limited to disaster recovery: 
E.g. you may also use the recorder as a simple of producing regression testcases for your webapplication.

Configuring your Server

All you need to do is add HttpRequestRecorder to your web.config's httpModules section and add a new configuration section for HttpRequestRecorder:

<configuration>
	<configSections>
		<section name="httpRequestRecorder"
               type="System.Configuration.NameValueSectionHandler " />
	</configSections>
	
	<httpRequestRecorder>
		<add key="OutputPath" value="~/" />
		<add key="BufferSize" value="10" />
	</httpRequestRecorder>
	
	<system.web>
		<httpModules>
			<add name="httpRequestRecorder" type="HttpRequestRecorder.RecorderModule, HttpRequestRecorder" />
		</httpModules>
	</system.web>
</configuration>

"OutputPath" denotes the location, where requests will be logged to
"BufferSize" denotes the number of events held in memory before flushing them to disk.

Replaying recorded events from Command Prompt
To replay recorded events, use PlayerConsole.exe. Type PlayerConsole /? for help.

Replaying recorded events using API
To replay events from within e.g. your NAnt build script, you may link to HttpRequestRecorder.dll assembly and use the class HttpRequestRecorder. Player:

// create the player instance
Player player = new Player( new Uri("http://localhost:81")  );
// pass a stream containing the xml-formatted events to the Play()-method
player.Play( new FileInfo("sampleevents.xml").OpenRead() );