HttpRequestHeaderCollection.Referer HttpRequestHeaderCollection.Referer HttpRequestHeaderCollection.Referer HttpRequestHeaderCollection.Referer HttpRequestHeaderCollection.Referer Property

Definition

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

public : Uri Referer { get; set; }
Uri Referer();

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

Property Value

Uri Uri Uri

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

See also