| title | IHttpCachePolicy::SetVaryByValue Method |
|---|---|
| ms.date | 10/07/2016 |
| description | Learn how to set the variable value, such as such as S_OK, E_INVALIDARG, and ERROR_ARITHMETIC_OVERFLOW, for the cache policy. |
| ms.assetid | 6822e2e0-50cb-1e07-5a9b-2b263d709c3b |
Sets the variable value for the cache policy.
virtual HRESULT SetVaryByValue(
PCSTR pszValue
) = 0; pszValue
A pointer to a null-terminated string that contains the custom value to append.
-or-
NULL.
An HRESULT. Possible values include, but are not limited to, those in the following table.
| Value | Description |
|---|---|
| S_OK | Indicates that the operation was successful. |
| E_INVALIDARG | Indicates that pszValue is NULL. |
| ERROR_ARITHMETIC_OVERFLOW | Indicates that the length of pszValue exceeds a maximum limit. |
CHttpModule derived classes that register for request or response events receive an IHttpContext pointer as a parameter on the corresponding virtual method. To set the variable value, call the IHttpContext::GetResponse method, the IHttpResponse::GetCachePolicy method, and finally the SetVaryByValue method.
SetVaryByValue behavior depends on implementation. You should use the following information as a guideline, but it may not be correct in all scenarios:
-
The current default implementer of the IHttpCachePolicy interface declares a
privatebuffer that contains variable data. During the construction of an implementer, this buffer is initialized to empty. -
SetVaryByValuereturns E_INVALIDARG immediately if thepszValueparameter is NULL. Otherwise, the internal buffer is expanded, if necessary, to hold the contents ofpszValueand the null-termination character. ThenpszValue, followed by the null-termination character, is copied into this buffer. Any data in the buffer before the call toSetVaryByValueis overwritten, if necessary, during the call toSetVaryByValue.
IHttpCachePolicy implementers are responsible for copying the pszValue parameter into a buffer, because the data associated with the pszValue parameter is not guaranteed to be valid after the call to SetVaryByValue.
IHttpCachePolicy clients are responsible for passing a null-terminated string to the SetVaryByValue method. Clients are also responsible for disposing of pszValue after the call to SetVaryByValue, because IHttpCachePolicy implementers copy pszValue into an internal buffer.
| 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 |