Modifier

Partager via


HttpCachePolicy.SetETag(String) Method

Definition

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