IIS 7 and Above
HttpLoggingModule does not log requests for 32-bit web applications o...
Last post Nov 12, 2018 08:38 AM by chuoiit30
Nov 05, 2018 05:55 AM|sudayakumar|LINK
HttpLoggingModule does not record any request logs when IHttpModuleContextContainer::SetModuleContext method is invoked in
OnBeginRequest. And this is seen only on systems running 32-bit applications in IIS10 on Win Server 2016.
I tried with the same application in IIS8 on Win Server 2012 r2 and it works just fine.
I have a 32-bit application running in IIS10 on Windows Server 2016.
I have written a new Http module to have custom request handling and I register this module with IIS10 as a native module. In method
REQUEST_NOTIFICATION_STATUS OnBeginRequest( IN IHttpContext * pHttpContext, IN IHttpEventProvider * pProvider) I invoke IHttpModuleContextContainer::SetModuleContext. Whenever I do this, no request logs are created by HttpLoggingModule.
When I remove the call to IHttpModuleContextContainer::SetModuleContext method, request logs work just fine.
To confirm this, I stripped all of my code in the Http Module and just retained the call to
IHttpModuleContextContainer::SetModuleContext method in
OnBeginRequest. After I register this module as a native module, request logs stop.
Any ideas as to what might be happening here? Or any workaround anyone can think of? Any help would be greatly appreciated.
Nov 06, 2018 01:08 PM|Brando Zhang|LINK
Could you please tell me which the version of the IIS10 you have used now?
Could you please share the http module codes you have used now for us to test?
Nov 07, 2018 09:17 PM|albigi|LINK
I have built a custom module which runs some dummy code within OnGlobalPreBeginRequest. Namely, I set the module context using a custom context class as follows:
NULL == storedContext ||
lstrcmpiW(qS, L"force") == 0
CStoredContext* myCtx = new CStoredContext;
I get a confirmation my code is run as my context class writes some bytes to the response body.
Still, I can see my request gets properly logged in IIS Logs.
Can you provide additional info regarding:
Nov 09, 2018 02:04 PM|albigi|LINK
So I did some further analysis and possibly found what is wrong with this scenario, but given I don't have your source code I cannot be 100% sure about it.
A similar behavior can happen whenever SetModuleContext is passed a
moduleId parameter which evaluates to 0 (or to any other id which is already in use).
A typically wrong usage of this API is as follows:
More details on how this API is designed to be used
HTTP_MODULE_ID is a unique key of each module and is opaque to the module developer.
The module registers with IIS by exposing RegisterModule. When IIS calls this function, IIS gives IHttpModuleRegistrationInfo that contains the ID of the module assigned by IIS. The Id can be retrieved by GetId method.
The module should use this ID to set and get its module context container – think it as a hash table with module as a unique key. Each module has its own storage. Imagine context container as a storage array with HTTP_MODULE_ID as the index
[moduleID:0, pHttpLoggingModuleContext], [moduleId:1, pIpRestrictionModuleContext], …..
Each module has its own slot, and each slot simply stores a pointer to an arbitrary data structure defined by the module. The moduleID is assigned by IIS upon module registration during startup. The module can use its ID to set and get its own context pointer:
When you call pContainer->SetModuleContext(pContextStorage, NULL), it is equivalent to setting the context pointer to the slot with index 0 (NULL cast to DWORD 0), which might happen to be the slot used by HTTP logging module. At this point any bad thing
can happen. Just not having the log might already be a lucky consequence.
Nov 12, 2018 08:38 AM|chuoiit30|LINK
, This is a great article. It gave me a lot of useful information. thank you very much.