I'm using an HttpModule to intercept each requests to my website in order to assign them authentication cookies, this is only a preliminary version but I'm having a static List in my HttpModule and for each new request I'm adding an element in the list. For testing purposes I'm writing them all to the response in order to see if my method is working but it is only ever giving me two values no matter how many users are in the list.
Here is a sample of my code, I've kept it simple by replacing the list of users with a list of strings.
public class SCCModule : IHttpModule
{
private static List<string> _users = new List<string>();
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += OnPreRequestHandlerExecute;
}
public void Dispose()
{
}
public void OnPreRequestHandlerExecute(Object source, EventArgs e)
{
HttpApplication app = (HttpApplication)source;
HttpResponse response = app.Context.Response;
HttpRequest request = app.Context.Request;
_users.Add("A user from " + DateTime.Now + "</br>");
foreach(var u in _users)
{
response.Write(u);
}
}
}
When loading a sample index.html from the website, it gives me :
A user from 10/18/2012 3:37:33 PM
A user from 10/18/2012 3:37:35 PM
Info on my setup : I'm running IIS7.5 to which I've added a Module, it is the first in order of priorities of execution. I have enabled Debugging in the web.config. My VisualStudio is set to build debug configuration and there is a post build event to directly copy my DLL to the bin folder of my website. I am attaching myself to the w3wp.exe process in order to debug it.
An interesting fact : when debugging. The first two times I hit refresh on the index.html page are going to trigger my breakpoint and after that it won't. Any new URI that I enter will only hit the breakpoint two times.
So why is it that only two results seem to go through even though I can refresh ten times ?
Fiddler result :
The problem was in IIS itself. Output caching was enabled thus the server was not sending any new pages even though the client was requesting new ones.
To result the issue I went to Output Caching -> Edit Feature Settings... -> I unchecked both Enable Cache and Enable Kernel cache.