HostString Struct¶
Represents the host portion of a URI can be used to construct URI’s properly formatted and encoded for use in HTTP headers.
- Namespace
Microsoft.AspNetCore.Http- Assemblies
- Microsoft.AspNetCore.Http.Abstractions
Syntax¶
public struct HostString : IEquatable<HostString>
-
struct
Microsoft.AspNetCore.Http.HostString
Constructors¶
-
HostString(System.String)¶ Creates a new HostString without modification. The value should be Unicode rather than punycode, and may have a port. IPv4 and IPv6 addresses are also allowed, and also may have ports.
public HostString(string value)
-
HostString(System.String, System.Int32) Creates a new HostString from its host and port parts.
Arguments: - host (System.String) – The value should be Unicode rather than punycode. IPv6 addresses must use square braces.
- port (System.Int32) – A positive, greater than 0 value representing the port in the host string.
public HostString(string host, int port)
-
Methods¶
-
Equals(Microsoft.AspNetCore.Http.HostString)¶ Compares the equality of the Value property, ignoring case.
Return type: System.Boolean public bool Equals(HostString other)
-
Equals(System.Object) Compares against the given object only if it is a HostString.
Return type: System.Boolean public override bool Equals(object obj)
-
FromUriComponent(System.String)¶ Creates a new HostString from the given URI component. Any punycode will be converted to Unicode.
Return type: Microsoft.AspNetCore.Http.HostString public static HostString FromUriComponent(string uriComponent)
-
FromUriComponent(System.Uri) Creates a new HostString from the host and port of the give Uri instance. Punycode will be converted to Unicode.
Return type: Microsoft.AspNetCore.Http.HostString public static HostString FromUriComponent(Uri uri)
-
GetHashCode()¶ Gets a hash code for the value.
Return type: System.Int32 public override int GetHashCode()
-
ToString()¶ Returns the value as normalized by ToUriComponent().
Return type: System.String public override string ToString()
-
ToUriComponent()¶ Returns the value properly formatted and encoded for use in a URI in a HTTP header. Any Unicode is converted to punycode. IPv6 addresses will have brackets added if they are missing.
Return type: System.String public string ToUriComponent()
-
Operators¶
-
Equality(Microsoft.AspNetCore.Http.HostString, Microsoft.AspNetCore.Http.HostString)¶ Compares the two instances for equality.
Return type: System.Boolean public static bool operator ==(HostString left, HostString right)
-
Inequality(Microsoft.AspNetCore.Http.HostString, Microsoft.AspNetCore.Http.HostString)¶ Compares the two instances for inequality.
Return type: System.Boolean public static bool operator !=(HostString left, HostString right)
-
Properties¶
-
Microsoft.AspNetCore.Http.HostString.HasValue¶ Return type: System.Boolean public bool HasValue { get; }
-
Microsoft.AspNetCore.Http.HostString.Host¶ Returns the value of the host part of the value. The port is removed if it was present. IPv6 addresses will have brackets added if they are missing.
Return type: System.String public string Host { get; }
-
Microsoft.AspNetCore.Http.HostString.Port¶ Returns the value of the port part of the host, or <returns>null</returns> if none is found.
Return type: System.Nullable<System.Int32> public int ? Port { get; }
-
Microsoft.AspNetCore.Http.HostString.Value¶ Returns the original value from the constructor.
Return type: System.String public string Value { get; }
-