Scott Hanselman

The ISAPI equivalent of Response.AppendToLog

August 24, 2005 Comment on this post [1] Posted in ASP.NET | Web Services
Sponsored By

In ASP.NET the Response object has a very useful method called AppendToLog. It was also around in the Classic ASP days. The Response object hangs off the HttpContext. If you're running with the context of an HttpRequest you can always get ahold of the current HttpContext via the static HttpContext.Current.

However, not everyone executes within managed code in ASP.NET. We've got a bunch of ISAPI code that is all C++/ATL/MFC. Within MFC you can get ahold of the context via the CHttpServerContext class. This class isn't as friendly as the whole Request/Response ASP model.

If you want to get to the really useful stuff you have to run through a 3rd Class API actually named ServerSupportFunction that's hanging off an Extension Control Block. Lame. The second parameter is a DWORD that indicates the function you're trying to call. Since we were trying to call the equivalent of Response.AppendToLog we would use HSE_APPEND_LOG_PARAMETER. The additional information you're trying to log will show up in the cs-uri-query extended field within IIS if you're using the W3C Extended Log File Format. You'll need to go into IIS Properties and enable the logging of this field.

So, doing this in managed code:


Is this in unmanaged "classic" C++ ISAPI:

                                m_pCHttpServerContext->m_pECB->ConnID , 
                                HSE_APPEND_LOG_PARAMETER , 
                                &dwFooLen , 

Big ups to Paul Gomes from Corillian for figuring this out! And no I'm not off vacation yet; my wife is asleep. :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
August 29, 2005 21:42
Do you know how to get a handle to the session object from an ISAPI Filter? Even a classic ASP session object (COM) would be helpful.


Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.