HttpCachePolicy.SetETag(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the ETag
HTTP header to the specified string.
public:
void SetETag(System::String ^ etag);
public void SetETag (string etag);
member this.SetETag : string -> unit
Public Sub SetETag (etag As String)
Parameters
- etag
- String
The text to use for the ETag
header.
Exceptions
etag
is null
.
The ETag
header has already been set.
-or-
The SetETagFromFileDependencies() has already been called.
Examples
The following code example demonstrates how to set the ETag
header to a custom value.
Response.Cache.SetETag("\"50f59e42f4d8bc1:cd7\"");
Response.Cache.SetETag("""50f59e42f4d8bc1:cd7""")
Remarks
The ETag
header is a unique identifier for a specific version of a document. It is used by clients to validate client-cached content to avoid requesting it again. Once an ETag
header is set, subsequent attempts to set it fail and an exception is thrown.
SetETag is introduced in the .NET Framework version 3.5. For more information, see Versions and Dependencies.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈