Condividi tramite


HttpRequestHeaderCollection.Referer Proprietà

Definizione

Ottiene o imposta l'URI che rappresenta il valore di un'intestazione HTTP referer in una richiesta HTTP.

public:
 property Uri ^ Referer { Uri ^ get(); void set(Uri ^ value); };
Uri Referer();

void Referer(Uri value);
public System.Uri Referer { get; set; }
var uri = httpRequestHeaderCollection.referer;
httpRequestHeaderCollection.referer = uri;
Public Property Referer As Uri

Valore della proprietà

Oggetto che rappresenta il valore di un'intestazione HTTP referer in una richiesta HTTP. Un valore Null indica che l'intestazione è assente.

Commenti

Il codice di esempio seguente mostra un metodo per impostare l'intestazione referer in un oggetto HttpRequestMessage usando la proprietà Referer nell'oggetto HttpRequestHeaderCollection.

public void DemonstrateHeaderRequestReferer() {
    var request = new HttpRequestMessage();

    // This is not typically set with a string.

    // Set the header with a strong type.
    // Uri is either in the Windows.Foundation namespace (JavaScript and C++)
    // or in the System.Net namespace (C#).
    var value = new Uri("http://example.com/");
    request.Headers.Referer = value;

    // Get the strong type out
    System.Diagnostics.Debug.WriteLine("Referer absolute uri: {0}", request.Headers.Referer.AbsoluteUri);

    // The ToString() is useful for diagnostics, too.
    System.Diagnostics.Debug.WriteLine("The Host ToString() results: {0}", request.Headers.Referer.ToString());
}

Si applica a

Vedi anche