HttpRequestHeaderCollection.Referer Property

Definition

Gets or sets the Uri that represents the value of a Referer HTTP header on an HTTP request.

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

Property Value

The object that represents the value of a Referer HTTP header on an HTTP request. A null value means that the header is absent.

Remarks

The following sample code shows a method to set the Referer header on an HttpRequestMessage object using the Referer property on the HttpRequestHeaderCollection object.

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());
}

Applies to

See also