HttpListenerRequest.RawUrl 属性

定义

获取客户端请求的 URL 信息(不包括主机和端口)。Gets the URL information (without the host and port) requested by the client.

public:
 property System::String ^ RawUrl { System::String ^ get(); };
public string? RawUrl { get; }
public string RawUrl { get; }
member this.RawUrl : string
Public ReadOnly Property RawUrl As String

属性值

String

String 包含此请求的原始 URL。A String that contains the raw URL for this request.

示例

下面的代码示例演示如何使用 RawUrl 属性。The following code example demonstrates using the RawUrl property.

public static void CheckTestUrl(HttpListener listener, HttpListenerRequest request)
{
    if (request.RawUrl == "/www.contoso.com/test/NoReply")
    {
        listener.Abort ();
        return;
    }
}
Public Shared Sub CheckTestUrl(ByVal listener As HttpListener, ByVal request As HttpListenerRequest)
    If request.RawUrl = "/www.contoso.com/test/NoReply" Then
        listener.Abort()
        Return
    End If
End Sub

注解

原始 URL 定义为后面包含域信息的 URL 部分。The raw URL is defined as the part of the URL following the domain information. 在 URL 字符串中 http://www.contoso.com/articles/recent.aspx ,原始 URL 是 /articles/recent.aspxIn the URL string http://www.contoso.com/articles/recent.aspx, the raw URL is /articles/recent.aspx. 原始 URL 包括查询字符串(如果存在)。The raw URL includes the query string, if present.

若要获取主机和端口信息,请使用 RemoteEndPoint 属性。To obtain the host and port information, use the RemoteEndPoint property.

适用于

另请参阅