System.Uri.PathAndQuery Property

Gets the Uri.AbsolutePath and Uri.Query properties separated by a question mark (?).

Syntax

public string PathAndQuery { get; }

Value

A string that contains the values of the Uri.AbsolutePath and Uri.Query properties.

Remarks

The Uri.PathAndQuery property contains the absolute path on the server and the query information sent with the request. It is identical to concatenating the Uri.AbsolutePath and Uri.Query properties.

The Uri.PathAndQuery property is escaped according to RFC 2396 by default. If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the Uri.PathAndQuery property is escaped according to RFC 3986 and RFC 3987.

For more information on IRI support, see the Remarks section for the Uri class.

Example

The following example uses the Uri.PathAndQuery property to extract the path and query information from a Uri instance.

C# Example

using System;

public class UriTest {
 public static void Main() {

 Uri baseUri = new Uri("http://www.contoso.com/");
 Uri myUri = new Uri(baseUri, "catalog/shownew.htm?date=today");
 
 Console.WriteLine(myUri.PathAndQuery);
 }
}

The output is

/catalog/shownew.htm?date=today

Requirements

Namespace: System
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0