PathString Struct

Provides correct escaping for Path and PathBase values when needed to reconstruct a request or redirect URI string

Namespace
Microsoft.AspNetCore.Http
Assemblies
  • Microsoft.AspNetCore.Http.Abstractions

Syntax

public struct PathString : IEquatable<PathString>
struct Microsoft.AspNetCore.Http.PathString

Constructors

PathString(System.String)

Initalize the path string with a given value. This value must be in unescaped format. Use PathString.FromUriComponent(value) if you have a path value which is in an escaped format.

Arguments:value (System.String) – The unescaped path to be assigned to the Value property.
public PathString(string value)

Methods

Add(Microsoft.AspNetCore.Http.PathString)

Adds two PathString instances into a combined PathString value.

Return type:Microsoft.AspNetCore.Http.PathString
Returns:The combined PathString value
public PathString Add(PathString other)
Add(Microsoft.AspNetCore.Http.QueryString)

Combines a PathString and QueryString into the joined URI formatted string value.

Return type:System.String
Returns:The joined URI formatted string value
public string Add(QueryString other)
Equals(Microsoft.AspNetCore.Http.PathString)

Compares this PathString value to another value. The default comparison is StringComparison.OrdinalIgnoreCase.

Arguments:other (Microsoft.AspNetCore.Http.PathString) – The second PathString for comparison.
Return type:System.Boolean
Returns:True if both PathString values are equal
public bool Equals(PathString other)
Equals(Microsoft.AspNetCore.Http.PathString, System.StringComparison)

Compares this PathString value to another value using a specific StringComparison type

Arguments:
Return type:

System.Boolean

Returns:

True if both PathString values are equal

public bool Equals(PathString other, StringComparison comparisonType)
Equals(System.Object)

Compares this PathString value to another value. The default comparison is StringComparison.OrdinalIgnoreCase.

Arguments:obj (System.Object) – The second PathString for comparison.
Return type:System.Boolean
Returns:True if both PathString values are equal
public override bool Equals(object obj)
FromUriComponent(System.String)

Returns an PathString given the path as it is escaped in the URI format. The string MUST NOT contain any value that is not a path.

Arguments:uriComponent (System.String) – The escaped path as it appears in the URI format.
Return type:Microsoft.AspNetCore.Http.PathString
Returns:The resulting PathString
public static PathString FromUriComponent(string uriComponent)
FromUriComponent(System.Uri)

Returns an PathString given the path as from a Uri object. Relative Uri objects are not supported.

Arguments:uri (System.Uri) – The Uri object
Return type:Microsoft.AspNetCore.Http.PathString
Returns:The resulting PathString
public static PathString FromUriComponent(Uri uri)
GetHashCode()

Returns the hash code for the PathString value. The hash code is provided by the OrdinalIgnoreCase implementation.

Return type:System.Int32
Returns:The hash code
public override int GetHashCode()
StartsWithSegments(Microsoft.AspNetCore.Http.PathString)

Determines whether the beginning of this Microsoft.AspNetCore.Http.PathString instance matches the specified Microsoft.AspNetCore.Http.PathString.

Arguments:other (Microsoft.AspNetCore.Http.PathString) – The Microsoft.AspNetCore.Http.PathString to compare.
Return type:System.Boolean
Returns:true if value matches the beginning of this string; otherwise, false.
public bool StartsWithSegments(PathString other)
StartsWithSegments(Microsoft.AspNetCore.Http.PathString, out Microsoft.AspNetCore.Http.PathString)

Determines whether the beginning of this PathString instance matches the specified Microsoft.AspNetCore.Http.PathString when compared using the specified comparison option and returns the remaining segments.

Arguments:
Return type:

System.Boolean

Returns:

true if value matches the beginning of this string; otherwise, false.

public bool StartsWithSegments(PathString other, out PathString remaining)
StartsWithSegments(Microsoft.AspNetCore.Http.PathString, System.StringComparison)

Determines whether the beginning of this Microsoft.AspNetCore.Http.PathString instance matches the specified Microsoft.AspNetCore.Http.PathString when compared using the specified comparison option.

Arguments:
Return type:

System.Boolean

Returns:

true if value matches the beginning of this string; otherwise, false.

public bool StartsWithSegments(PathString other, StringComparison comparisonType)
StartsWithSegments(Microsoft.AspNetCore.Http.PathString, System.StringComparison, out Microsoft.AspNetCore.Http.PathString)

Determines whether the beginning of this Microsoft.AspNetCore.Http.PathString instance matches the specified Microsoft.AspNetCore.Http.PathString and returns the remaining segments.

Arguments:
Return type:

System.Boolean

Returns:

true if value matches the beginning of this string; otherwise, false.

public bool StartsWithSegments(PathString other, StringComparison comparisonType, out PathString remaining)
ToString()

Provides the path string escaped in a way which is correct for combining into the URI representation.

Return type:System.String
Returns:The escaped path value
public override string ToString()
ToUriComponent()

Provides the path string escaped in a way which is correct for combining into the URI representation.

Return type:System.String
Returns:The escaped path value
public string ToUriComponent()

Operators

Addition(Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.PathString)

Operator call through to Add

Arguments:
Return type:

Microsoft.AspNetCore.Http.PathString

Returns:

The PathString combination of both values

public static PathString operator +(PathString left, PathString right)
Addition(Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.QueryString)

Operator call through to Add

Arguments:
Return type:

System.String

Returns:

The PathString combination of both values

public static string operator +(PathString left, QueryString right)
Addition(Microsoft.AspNetCore.Http.PathString, System.String)
Arguments:
Return type:

System.String

Returns:

The ToString combination of both values

public static string operator +(PathString left, string right)
Addition(System.String, Microsoft.AspNetCore.Http.PathString)
Arguments:
Return type:

System.String

Returns:

The ToString combination of both values

public static string operator +(string left, PathString right)
Equality(Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.PathString)

Operator call through to Equals

Arguments:
Return type:

System.Boolean

Returns:

True if both PathString values are equal

public static bool operator ==(PathString left, PathString right)
Implicit(Microsoft.AspNetCore.Http.PathString to System.String)

Implicitly calls ToString().

Return type:System.String
public static implicit operator string (PathString path)
Implicit(System.String to Microsoft.AspNetCore.Http.PathString)

Implicitly creates a new PathString from the given string.

Return type:Microsoft.AspNetCore.Http.PathString
public static implicit operator PathString(string s)
Inequality(Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.PathString)

Operator call through to Equals

Arguments:
Return type:

System.Boolean

Returns:

True if both PathString values are not equal

public static bool operator !=(PathString left, PathString right)

Fields

Empty()

Represents the empty path. This field is read-only.

Return type:Microsoft.AspNetCore.Http.PathString
public static readonly PathString Empty

Properties

Microsoft.AspNetCore.Http.PathString.HasValue

True if the path is not empty

Return type:System.Boolean
public bool HasValue { get; }
Microsoft.AspNetCore.Http.PathString.Value

The unescaped path value

Return type:System.String
public string Value { get; }