Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
struct Microsoft.​AspNetCore.​Http.​HostString
Assembly: Microsoft.AspNetCore.Http.Abstractions
Implemented Interfaces
Represents the host portion of a URI can be used to construct URI's properly formatted and encoded for use in HTTP headers.
Properties
public
string
Value
Returns the original value from the constructor.
public
bool
HasValue
Returns true if the host is set.
public
string
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.
public
int?
Port
Returns the value of the port part of the host, or <value>null</value> if none is found.
Methods
public
string
ToString​()
Returns the value as normalized by ToUriComponent().
Returns The value as normalized by <see cref="M:Microsoft.AspNetCore.Http.HostString.ToUriComponent" /> .
public
string
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.
Returns The <see cref="T:Microsoft.AspNetCore.Http.HostString" /> value formated for use in a URI or HTTP header.
public static
HostString
FromUriComponent​(string uriComponent)
Creates a new HostString from the given URI component.
Any punycode will be converted to Unicode.
Returns The <see cref="T:Microsoft.AspNetCore.Http.HostString" /> that was created.
uriComponent
The URI component string to create a <see cref="T:Microsoft.AspNetCore.Http.HostString" /> from.
public static
HostString
FromUriComponent​(System.​Uri uri)
Creates a new HostString from the host and port of the give Uri instance.
Punycode will be converted to Unicode.
Returns The <see cref="T:Microsoft.AspNetCore.Http.HostString" /> that was created.
uri
The <see cref="T:System.Uri" /> to create a <see cref="T:Microsoft.AspNetCore.Http.HostString" /> from.
public static
bool
MatchesAny​(Extensions.​Primitives.​StringSegment value,
System.​Collections.​Generic.​IList<​Extensions.​Primitives.​StringSegment> patterns)
Matches the host portion of a host header value against a list of patterns.
The host may be the encoded punycode or decoded unicode form so long as the pattern
uses the same format.
Returns <see langword="true" /> if <paramref name="value" /> matches any of the patterns.
value
Host header value with or without a port.
patterns
A set of pattern to match, without ports.
Remarks
The port on the given value is ignored. The patterns should not have ports.
The patterns may be exact matches like "example.com", a top level wildcard "*"
that matches all hosts, or a subdomain wildcard like "*.example.com" that matches
"abc.example.com:443" but not "example.com:443".
Matching is case insensitive.
public
bool
Equals​(HostString other)
Compares the equality of the Value property, ignoring case.
Returns <see langword="true" /> if they have the same value.
other
The <see cref="T:Microsoft.AspNetCore.Http.HostString" /> to compare against.
public
bool
Equals​(object obj)
Compares against the given object only if it is a HostString.
Returns <see langword="true" /> if they have the same value.
obj
The <see cref="T:System.Object" /> to compare against.
public
int
GetHashCode​()
Gets a hash code for the value.
Returns The hash code as an <see cref="T:System.Int32" /> .
protected
void
Finalize​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object