HttpResponse.AppendHeader(String, String) Método

Definição

Adiciona um cabeçalho HTTP ao fluxo de saída.Adds an HTTP header to the output stream.

public:
 void AppendHeader(System::String ^ name, System::String ^ value);
public void AppendHeader (string name, string value);
member this.AppendHeader : string * string -> unit
Public Sub AppendHeader (name As String, value As String)

Parâmetros

name
String

O nome do cabeçalho HTTP para adicionar ao fluxo de saída.The name of the HTTP header to add to the output stream.

value
String

A cadeia de caracteres a ser acrescentada ao cabeçalho.The string to append to the header.

Exceções

O cabeçalho será anexado depois que os cabeçalhos HTTP tiverem sido enviados.The header is appended after the HTTP headers have been sent.

Exemplos

O exemplo a seguir chama o AppendHeader método para adicionar um cabeçalho personalizado ao HttpResponse objeto enviado para o cliente solicitante.The following example calls the AppendHeader method to add a custom header to the HttpResponse object sent to the requesting client.

Response.AppendHeader("CustomAspNetHeader", "Value1");
Response.AppendHeader("CustomAspNetHeader", "Value1")

Comentários

Se você usar o AppendHeader método para enviar cabeçalhos específicos de cache e, ao mesmo tempo, usar o modelo de objeto de cache ( Cache ) para definir a política de cache, os cabeçalhos de resposta http que pertencem ao cache (,,, Cache-Control Expires Last-Modified Pragma e Vary ) poderão ser excluídos quando o modelo de objeto de cache for usado.If you use the AppendHeader method to send cache-specific headers and at the same time use the cache object model (Cache) to set cache policy, HTTP response headers that pertain to caching (Cache-Control, Expires, Last-Modified, Pragma, and Vary) might be deleted when the cache object model is used. Esse comportamento permite que o ASP.NET Mantenha as configurações mais restritivas.This behavior enables ASP.NET to maintain the most restrictive settings. Por exemplo, considere uma página que inclui controles de usuário.For example, consider a page that includes user controls. Se esses controles tiverem políticas de cache conflitantes, a política de cache mais restritiva será usada.If those controls have conflicting cache policies, the most restrictive cache policy will be used. Se um controle de usuário definir o cabeçalho " Cache-Control: Public " e outro controle de usuário definir o cabeçalho mais restritivo " Cache-Control: Private " por meio de chamadas para SetCacheability , o Cache-Control: Private cabeçalho "" será enviado com a resposta.If one user control sets the header "Cache-Control: Public" and another user control sets the more restrictive header "Cache-Control: Private" via calls to SetCacheability, then the "Cache-Control: Private" header will be sent with the response.

Para obter uma lista de cabeçalhos HTTP/1.1 padrão, consulte definições de campo de cabeçalho.For a list of standard HTTP/1.1 headers, see Header field definitions.

Aplica-se a