| title | IHttpServer::GetFileInfo Method |
|---|---|
| description | Learn how the GetFileInfo method returns an IHttpFileInfo interface for a specific file path. |
| ms.date | 10/07/2016 |
| ms.assetid | 1c3d91fe-062b-93c1-c5ad-e0dda028d987 |
Returns an IHttpFileInfo interface for a specific file path.
virtual HRESULT GetFileInfo(
IN PCWSTR pszPhysicalPath,
IN HANDLE hUserToken,
IN PSID pSid,
IN PCWSTR pszVrPath,
IN HANDLE hVrToken,
IN BOOL fCache,
OUT IHttpFileInfo** ppFileInfo,
IN IHttpTraceContext* pHttpTraceContext = NULL
) = 0; pszPhysicalPath
[IN] A pointer to a string that contains the physical path to a file.
hUserToken
[IN] A HANDLE that contains the token for the impersonation user; otherwise, NULL.
pSid
[IN] A pointer to a security identifier (SID) that contains the security ID for the impersonation user; otherwise, NULL.
pszVrPath
[IN] A pointer to a string that contains the virtual path to register for change notifications; otherwise, NULL.
hVrToken
[IN] A HANDLE that contains the impersonation token to register for change notifications; otherwise, NULL.
fCache
[IN] true to indicate that the file should be cached; otherwise, false.
ppFileInfo
[OUT] A dereferenced pointer to an IHttpFileInfo interface.
pHttpTraceContext
[IN] A pointer to an optional IHttpTraceContext interface.
An HRESULT. Possible values include, but are not limited to, those in the following table.
| Value | Definition |
|---|---|
| S_OK | Indicates that the operation was successful. |
| E_FAIL | Indicates that the call to GetFileInfo was made while the module host was terminating. |
The IHttpServer::GetFileInfo method creates an IHttpFileInfo interface for a specific path. This method differs from the IHttpContext::GetFileInfo method, which returns an IHttpFileInfo interface for the file that IIS is processing within a request context.
The pszPhysicalPath and ppFileInfo parameters are required to create an IHttpFileInfo interface. The pszPhysicalPath parameter specifies the path to the file, and the ppFileInfo parameter defines the pointer that IIS will populate with the corresponding IHttpFileInfo interface.
The pszVrPath and hVrToken parameters are optional, and you should set them to NULL if you do not use them. These parameters specify, respectively, the virtual path and impersonation token to use when a module registers for change notifications (for example, if you request caching by setting the fCache parameter to true).
Note
Other configuration settings may prevent IIS from caching the file, even if you specify true for the fCache parameter.
The hUserToken and pSid parameters are also optional, and you should set them to NULL if you do not use them. These parameters specify, respectively, the token and SID for the impersonation user. The remaining optional parameter, pHttpTraceContext, specifies the IHttpTraceContext interface for tracing.
The following code example demonstrates how to create an HTTP module that performs the following tasks:
-
Registers for the RQ_BEGIN_REQUEST notification.
-
Creates a CHttpModule class that contains an OnBeginRequest method. When a client requests a file, the
OnBeginRequestmethod performs the following tasks:-
Maps a path to a relative URL by using the IHttpContext::MapPath method.
-
Creates an
IHttpFileInfointerface for the file path by using theIHttpServer::GetFileInfomethod. -
Retrieves the entity tag for the file by using the IHttpFileInfo::GetETag method.
-
Returns the entity tag to the client by using the IHttpResponse::WriteEntityChunks method.
-
-
Removes the
CHttpModuleclass from memory and then exits.
[!code-cppIHttpServerGetFileInfo#1]
For more information on how to create and deploy a native DLL module, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.
You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.
| Type | Description |
|---|---|
| Client | - IIS 7.0 on [!INCLUDEwinvista] - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
| Server | - IIS 7.0 on [!INCLUDEwinsrv2008] - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
| Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100] |
| Header | Httpserv.h |