This is what I came up with:
namespace TestServiceHttpAuthentication
{
public class AuthenticateRequestHttpModule : IHttpModule
{
private HttpApplication mHttpApp;
public void Init(HttpApplication httpApp)
{
this.mHttpApp = httpApp;
mHttpApp.AuthenticateRequest += new EventHandler(OnAuthentication);
}
void OnAuthentication(object sender, EventArgs a)
{
HttpApplication application = (HttpApplication)sender;
HttpRequest request = application.Context.Request;
//WindowsIdentity identity = (WindowsIdentity)application.Context.User.Identity;
StreamWriter sw = new StreamWriter(request.MapPath("Test.txt"), true);
sw.WriteLine(application.Context.Request.HttpMethod.ToString());
sw.WriteLine(application.Context.Request.Headers.Count.ToString());
NameValueCollection coll;
coll=application.Context.Request.Headers;
string[] arr1 = coll.AllKeys;
for(int loop1=0;loop1<arr1.length;loop1++)>
{
sw.WriteLine(arr1[loop1].ToString());
string[] arr2=coll.GetValues(arr1[loop1]);
for(int loop2=0;loop2<arr2.length;loop2++)>
{
sw.WriteLine(arr2[loop2].ToString());
}
}
sw.Flush();
sw.Close();
}
public void Dispose()
{ }
}
}
And in the web.config:
<httpModules>
add name="AuthenticateRequestHttpModule" type="TestServiceHttpAuthentication.AuthenticateRequestHttpModule, TestServiceHttpAuthentication" />
</httpModules>
Now I can read from the HTTP header, validate the values from specific key/value pairs.
Thanks for those who've thought with me.
Jeroen