HttpRequestHeaderCollection.Referer 屬性

定義

取得或設定 URI ,表示 HTTP 要求上 參考者 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

屬性值

物件,表示 HTTP 要求上 參考者 HTTP 標頭的值。 Null 值表示標頭不存在。

備註

下列範例程式碼示範使用HttpRequestHeaderCollection物件上的 Referer 屬性,在HttpRequestMessage物件上設定Referer標頭的方法。

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

適用於

另請參閱