I have an isapi filter written in C. Its only purpose is to set a cookie (using AddResponseHeaders function) on every request when the IIS SF_NOTIFY_PREPROC_HEADERS notification occurs. Also, on this web server I have an asp.net application that, from a simple button click handler, sets the same exact cookie with a different value. This means that on the postback request when a user clicks the asp.net button, the 2 cookies are set.
Now the problem. On IIS 6, the cookie set by the asp.net application has precedence and the client browser keeps the correct value coming from the asp.net app. This is the desired behavior (on such requests, I can see in the response headers that the asp.net application cookie comes after the isapi one). Now I'm moving this setup on IIS 7.5 and I see the opposite, the isapi cookie has precedence and the client gets the wrong value after the asp.net button click.
I've been reading on the subject quite a bit and I don't understand why this is happening. According to this, there shouldn't be any difference since the IIS notification that I respond to is supposedly coming before the aspx handler execution. I validated this order through debugging and it is the same using classic and integrated pipeline.
Right now I settled on manually reordering my "set-cookie" headers in the isapi filter using the SF_NOTIFY_SEND_RESPONSE notification, but I would be grateful to know why this happens. Also, I tried to use an http module to do that reordering, but I couldn't find a way to access the cookie being set by the isapi filter using the Module PreSendRequestHeaders event. I could see the headers coming from the asp.net application, but that's all.
Anyone can shed some light on these interrogations?
Thanks