Share via


UriBuilder.Query 속성

정의

비어 있지 않은 경우 선행 '?' 문자를 포함하여 URI에 포함된 쿼리 정보를 가져오거나 설정합니다.

public:
 property System::String ^ Query { System::String ^ get(); void set(System::String ^ value); };
public string Query { get; set; }
member this.Query : string with get, set
Public Property Query As String

속성 값

URI에 포함된 쿼리 정보입니다.

예제

다음 예제에서는 Query 속성입니다.

UriBuilder^ baseUri = gcnew UriBuilder 
    ("http://www.contoso.com/default.aspx?Param1=7890");
String^ queryToAppend = "param2=1234";
if (baseUri->Query != nullptr && baseUri->Query->Length > 1)
{
    // Note: In .NET Core and .NET 5+, you can simplify by removing
    // the call to Substring(), which removes the leading "?" character.
    baseUri->Query = baseUri->Query->Substring(1)+ "&" + queryToAppend;
}
else
{
    baseUri->Query = queryToAppend;
}
UriBuilder baseUri = new UriBuilder("http://www.contoso.com/default.aspx?Param1=7890");
string queryToAppend = "param2=1234";

if (baseUri.Query != null && baseUri.Query.Length > 1)
    // Note: In .NET Core and .NET 5+, you can simplify by removing
    // the call to Substring(), which removes the leading "?" character.
    baseUri.Query = baseUri.Query.Substring(1) + "&" + queryToAppend; 
else
    baseUri.Query = queryToAppend;
open System

let baseUri = UriBuilder "http://www.contoso.com/default.aspx?Param1=7890"
let queryToAppend = "param2=1234"

baseUri.Query <-
    if baseUri.Query <> null && baseUri.Query.Length > 1 then
        // Note: In .NET Core and .NET 5+, you can simplify by removing
        // the call to Substring(), which removes the leading "?" character.
        baseUri.Query.Substring 1 + "&" + queryToAppend 
    else
        queryToAppend

설명

Query 속성 URI에 포함 된 쿼리 정보를 포함 합니다. 쿼리 정보는 물음표 (?)로 경로 정보에서 분리 되 고 URI의 끝까지 계속 합니다. 반환되는 쿼리 정보에는 선행 물음표가 포함됩니다. 속성을 설정할 때 다음을 수행 Query 합니다.

  • .NET Framework 문자열이 이미 물음표로 시작하는 경우에도 항상 문자열 앞에 물음표가 추가됩니다.
  • .NET 5(및 .NET Core) 이상 버전에서는 아직 없는 경우 문자열 앞에 물음표가 추가됩니다.

쿼리 정보는 RFC 2396에 따라 이스케이프 됩니다.

참고

.NET Framework 기존 쿼리 정보에 값을 추가하려면 속성을 새 값으로 설정하기 전에 선행 물음표를 제거해야 합니다. .NET Framework 속성을 설정할 때 항상 물음표 앞에 추가하기 때문입니다. .NET 5(및 .NET Core) 이상 버전은 선행 물음표에 관대하며 필요한 경우에만 앞에 붙습니다.

적용 대상

추가 정보