102 instantiations of HostString
Certificate.Optional.Sample (1)
Startup.cs (1)
25new HostString(Program.HostWithCert, context.HttpContext.Connection.LocalPort),
HttpAbstractions.SampleApp (1)
Program.cs (1)
16request.Host = new HostString("Host:port");
Microsoft.AspNetCore.Components.Endpoints.Tests (4)
EndpointHtmlRendererTest.cs (3)
759ctx.Request.Host = new HostString("localhost"); 790ctx.Request.Host = new HostString("localhost"); 1658context.Request.Host = new HostString("localhost");
RazorComponentResultTest.cs (1)
473result.Request.Host = new HostString("test");
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (2)
Infrastructure\TestHelpers.cs (1)
27httpContext.Request.Host = new HostString("localhost");
JsonTranscodingServerCallContextTests.cs (1)
64httpContext.Request.Host = new HostString("localhost");
Microsoft.AspNetCore.HostFiltering (1)
MiddlewareConfigurationManager.cs (1)
67var host = new HostString(entry).ToUriComponent();
Microsoft.AspNetCore.Hosting.Tests (6)
HostingApplicationDiagnosticsTests.cs (5)
243c.Request.Host = new HostString("localhost"); 302c.Request.Host = new HostString("localhost"); 362c.Request.Host = new HostString("localhost"); 417c.Request.Host = new HostString("localhost"); 1052c.Request.Host = new HostString("localhost");
Internal\HostingRequestStartLogTests.cs (1)
20mockRequest.Setup(request => request.Host).Returns(new HostString(input));
Microsoft.AspNetCore.Http.Abstractions (2)
HostString.cs (2)
192return new HostString(uriComponent); 205return new HostString(uri.GetComponents(
Microsoft.AspNetCore.Http.Abstractions.Tests (13)
HostStringTest.cs (12)
17ExceptionAssert.ThrowsArgumentOutOfRange(() => new HostString("localhost", port), "port", "The value must be greater than zero."); 33var hostString = new HostString(sourceValue); 54var hostString = new HostString(sourceValue); 68var hostString = new HostString(sourceValue); 86var hostString = new HostString(sourceHost, sourcePort); 101Assert.Equal(default(HostString), new HostString(string.Empty)); 102Assert.Equal(default(HostString), new HostString(string.Empty)); 104Assert.True(new HostString(string.Empty) == default(HostString)); 105Assert.True(default(HostString) == new HostString(string.Empty)); 112var hostString = new HostString("example.com"); 122var hostString = new HostString("example.com"); 125Assert.NotEqual(hostString, new HostString(string.Empty));
PathStringTests.cs (1)
97var host = new HostString("localhost:80");
Microsoft.AspNetCore.Http.Extensions.Tests (11)
UriHelperTests.cs (11)
28var result = UriHelper.BuildAbsolute("http", new HostString(string.Empty)); 36var result = UriHelper.BuildAbsolute("http", new HostString("my.HoΨst:80"), new PathString("/un?escaped/base"), new PathString("/un?escaped"), 74new HostString(host), 88request.Host = new HostString("my.HoΨst:80"); 103request.Host = new HostString("my.HoΨst:80"); 136var host = new HostString(); 143Assert.Equal(host, new HostString(expectedHost)); 153var host = new HostString("example.com"); 160var resHost = new HostString(); 176var resHost = new HostString(); 188var resHost = new HostString();
Microsoft.AspNetCore.Http.Tests (5)
ApplicationBuilderTests.cs (1)
93httpContext.Request.Host = new HostString("localhost:5000");
Internal\DefaultHttpRequestTests.cs (4)
112request.Host = new HostString("löcalhöst"); 304context.Request.Host = new HostString("localhost", 8080); 318context.Request.Host = new HostString("localhost"); 332context.Request.Host = new HostString("localhost", 8080);
Microsoft.AspNetCore.HttpOverrides (1)
ForwardedHeadersMiddleware.cs (1)
81var host = new HostString(entry).ToUriComponent();
Microsoft.AspNetCore.HttpsPolicy (2)
HttpsRedirectionMiddleware.cs (2)
94host = new HostString(host.Host, port); 98host = new HostString(host.Host);
Microsoft.AspNetCore.Mvc.Core (2)
RequireHttpsAttribute.cs (2)
80host = new HostString(host.Host, optionsAccessor.Value.SslPort.Value); 85host = new HostString(host.Host);
Microsoft.AspNetCore.Mvc.Core.Test (15)
Routing\ControllerLinkGeneratorExtensionsTest.cs (5)
30linkGenerator.GetUriByAction((string)null, "Home", null, null, new("localhost"))); 34linkGenerator.GetUriByAction("Index", null, null, null, new("localhost"))); 38linkGenerator.GetUriByAction("Index", "Home", null, null, new("localhost"))); 152new HostString("example.com"), 178httpContext.Request.Host = new HostString("example.com");
Routing\PageLinkGeneratorExtensionsTest.cs (2)
122new HostString("example.com"), 148httpContext.Request.Host = new HostString("example.com");
Routing\UrlHelperBaseTest.cs (1)
126context.Request.Host = new HostString(host);
Routing\UrlHelperExtensionsTest.cs (6)
614Host = new HostString(expectedHost), 649Host = new HostString(expectedHost), 684Host = new HostString("www.asp.net"), 722Host = new HostString(expectedHost), 770Host = new HostString(expectedHost), 818Host = new HostString("www.asp.net"),
Routing\UrlHelperTestBase.cs (1)
1153context.Request.Host = new HostString(host);
Microsoft.AspNetCore.OutputCaching.Tests (3)
OutputCacheKeyProviderTests.cs (3)
23context.HttpContext.Request.Host = new HostString("example.com", 80); 40context.HttpContext.Request.Host = new HostString("example.com", 80); 301context.HttpContext.Request.Host = new HostString("example.com" + KeyDelimiter, 80);
Microsoft.AspNetCore.ResponseCaching.Tests (1)
ResponseCachingKeyProviderTests.cs (1)
21context.HttpContext.Request.Host = new HostString("example.com", 80);
Microsoft.AspNetCore.Rewrite (6)
RedirectRule.cs (2)
70host = new HostString(newPath.Substring(schemeSplit)); 75host = new HostString(newPath.Substring(schemeSplit, pathSplit - schemeSplit));
RedirectToHttpsRule.cs (2)
24host = new HostString(host.Host, port); 29host = new HostString(host.Host);
RedirectToNonWwwRule.cs (1)
54new HostString(request.Host.Value.Substring(4)), // We verified the hostname begins with "www." already.
RedirectToWwwRule.cs (1)
54new HostString($"www.{context.HttpContext.Request.Host.Value}"),
Microsoft.AspNetCore.Rewrite.Tests (3)
IISUrlRewrite\ServerVariableTests.cs (1)
140context.Request.Host = new HostString("example.com");
PatternSegments\ServerNameSegmentTests.cs (1)
21httpContext.Request.Host = new HostString(host, port);
PatternSegments\UrlSegmentTests.cs (1)
30httpContext.Request.Host = new HostString(host, port);
Microsoft.AspNetCore.Routing.Tests (17)
DefaultLinkGeneratorTest.cs (11)
56var uri = linkGenerator.GetUriByAddress(0, values: null, "http", new HostString("example.com")); 123new HostString("example.com")); 140httpContext.Request.Host = new HostString("example.com"); 255new HostString("example.com"), 273httpContext.Request.Host = new HostString("example.com"); 395new HostString("example.com"), 415httpContext.Request.Host = new HostString("example.com"); 440httpContext.Request.Host = new HostString("example.com"); 464httpContext.Request.Host = new HostString("example.com"); 511httpContext.Request.Host = new HostString("example.com"); 520host: new HostString("example.com:5000"),
LinkGeneratorEndpointNameExtensionsTest.cs (2)
109new HostString("example.com"), 129httpContext.Request.Host = new HostString("example.com");
LinkGeneratorRouteValuesAddressExtensionsTest.cs (3)
125new HostString("example.com"), 151httpContext.Request.Host = new HostString("example.com"); 183httpContext.Request.Host = new HostString("example.com");
Matching\HostMatcherPolicyIntegrationTestBase.cs (1)
392httpContext.Request.Host = new HostString(host);
Microsoft.AspNetCore.TestHost (3)
ClientHandler.cs (1)
176req.Host = new HostString(req.Host.Host);
TestServer.cs (1)
219request.Host = new HostString(request.Host.Host);
WebSocketClient.cs (1)
68? new HostString(HostString.FromUriComponent(uri).Host)
Mvc.RoutingWebSite (3)
Controllers\LG1Controller.cs (3)
100host: new HostString("www.example.com"), 113host: new HostString("www.example.com"), 123host: new HostString("www.example.com"),
90 references to HostString
Microsoft.AspNetCore.HeaderParsing (2)
HostHeaderValue.cs (2)
74var hs = HostString.FromUriComponent(value);
Microsoft.AspNetCore.HostFiltering (1)
HostFilteringMiddleware.cs (1)
103if (allowedHosts is not null && HostString.MatchesAny(new StringSegment(host), allowedHosts))
Microsoft.AspNetCore.Hosting (1)
Internal\HostingApplicationDiagnostics.cs (1)
453[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HostString))]
Microsoft.AspNetCore.Http (2)
Internal\DefaultHttpRequest.cs (2)
115public override HostString Host 117get { return HostString.FromUriComponent(Headers.Host.ToString()); }
Microsoft.AspNetCore.Http.Abstractions (19)
HostString.cs (17)
18public readonly struct HostString : IEquatable<HostString> 134/// <returns>The <see cref="HostString"/> value formated for use in a URI or HTTP header.</returns> 160/// <param name="uriComponent">The URI component string to create a <see cref="HostString"/> from.</param> 161/// <returns>The <see cref="HostString"/> that was created.</returns> 162public static HostString FromUriComponent(string uriComponent) 199/// <param name="uri">The <see cref="Uri"/> to create a <see cref="HostString"/> from.</param> 200/// <returns>The <see cref="HostString"/> that was created.</returns> 201public static HostString FromUriComponent(Uri uri) 279/// <param name="other">The <see cref="HostString"/> to compare against.</param> 281public bool Equals(HostString other) 301return obj is HostString value && Equals(value); 318/// <returns><see langword="true" /> if both <see cref="HostString"/>'s have the same value.</returns> 319public static bool operator ==(HostString left, HostString right) 329/// <returns><see langword="true" /> if both <see cref="HostString"/>'s values are not equal.</returns> 330public static bool operator !=(HostString left, HostString right)
HttpRequest.cs (2)
46public abstract HostString Host { get; set; } 167public HostString Host => _request.Host;
Microsoft.AspNetCore.Http.Abstractions.Tests (15)
HostStringTest.cs (14)
33var hostString = new HostString(sourceValue); 54var hostString = new HostString(sourceValue); 68var hostString = new HostString(sourceValue); 86var hostString = new HostString(sourceHost, sourcePort); 101Assert.Equal(default(HostString), new HostString(string.Empty)); 102Assert.Equal(default(HostString), new HostString(string.Empty)); 104Assert.True(new HostString(string.Empty) == default(HostString)); 105Assert.True(default(HostString) == new HostString(string.Empty)); 112var hostString = new HostString("example.com"); 115Assert.NotEqual(default(HostString), hostString); 122var hostString = new HostString("example.com"); 146Assert.True(HostString.MatchesAny(host, new StringSegment[] { pattern })); 165Assert.False(HostString.MatchesAny(host, new StringSegment[] { pattern })); 171Assert.Throws<FormatException>(() => HostString.MatchesAny("example.com:1abc", new StringSegment[] { "example.com" }));
PathStringTests.cs (1)
97var host = new HostString("localhost:80");
Microsoft.AspNetCore.Http.Extensions (7)
RequestHeaders.cs (2)
214public HostString Host 218return HostString.FromUriComponent(Headers.Host.ToString());
UriHelper.cs (5)
53HostString host, 108out HostString host, 150host = HostString.FromUriComponent(uri.Substring(startIndex, limit - startIndex)); 167host: HostString.FromUriComponent(uri), 242/// Initializes the URI <see cref="string"/> for <see cref="BuildAbsolute(string, HostString, PathString, PathString, QueryString, FragmentString)"/>.
Microsoft.AspNetCore.Http.Extensions.Tests (5)
UriHelperTests.cs (5)
136var host = new HostString(); 153var host = new HostString("example.com"); 160var resHost = new HostString(); 176var resHost = new HostString(); 188var resHost = new HostString();
Microsoft.AspNetCore.Http.Results.Tests (2)
TestLinkGenerator.cs (2)
23public override string GetUriByAddress<TAddress>(HttpContext httpContext, TAddress address, RouteValueDictionary values, RouteValueDictionary ambientValues = null, string scheme = null, HostString? host = null, PathString? pathBase = null, FragmentString fragment = default, LinkOptions options = null) 26public override string GetUriByAddress<TAddress>(TAddress address, RouteValueDictionary values, string scheme, HostString host, PathString pathBase = default, FragmentString fragment = default, LinkOptions options = null)
Microsoft.AspNetCore.Http.Tests (2)
Internal\DefaultHttpRequestTests.cs (2)
75var host = request.Host; 95var host = request.Host;
Microsoft.AspNetCore.HttpOverrides (2)
ForwardedHeadersMiddleware.cs (2)
276&& (_allowAllHosts || HostString.MatchesAny(set.Host, _allowedHosts!))) 360request.Host = HostString.FromUriComponent(currentValues.Host);
Microsoft.AspNetCore.HttpsPolicy (1)
HttpsRedirectionMiddleware.cs (1)
91var host = context.Request.Host;
Microsoft.AspNetCore.Mvc.Core (5)
RequireHttpsAttribute.cs (1)
76var host = request.Host;
Routing\ControllerLinkGeneratorExtensions.cs (2)
141HostString? host = default, 193HostString host,
Routing\PageLinkGeneratorExtensions.cs (2)
142HostString? host = default, 194HostString host,
Microsoft.AspNetCore.Mvc.Core.Test (2)
RequireHttpsAttributeTests.cs (2)
73requestContext.Request.Host = HostString.FromUriComponent(host); 175requestContext.Request.Host = HostString.FromUriComponent(uri);
Microsoft.AspNetCore.Rewrite (6)
RedirectRule.cs (2)
59var host = default(HostString);
RedirectToHttpsRule.cs (1)
19var host = context.HttpContext.Request.Host;
RedirectToWwwHelper.cs (1)
42public static void SetRedirect(RewriteContext context, HostString newHost, int statusCode)
RewriteRule.cs (1)
58HostString host;
UrlActions\RewriteAction.cs (1)
65HostString host;
Microsoft.AspNetCore.Routing (12)
DefaultLinkGenerator.cs (3)
125HostString? host = default, 153HostString host, 239HostString host,
LinkGeneratorEndpointNameAddressExtensions.cs (4)
189HostString? host = default, 248HostString? host = default, 301HostString host, 350HostString host,
LinkGeneratorRouteValuesAddressExtensions.cs (4)
189HostString? host = default, 248HostString? host = default, 301HostString host, 344HostString host,
Matching\HostMatcherPolicy.cs (1)
335var hostString = httpContext.Request.Host;
Microsoft.AspNetCore.Routing.Abstractions (2)
LinkGenerator.cs (2)
115HostString? host = default, 151HostString host,
Microsoft.AspNetCore.TestHost (4)
ClientHandler.cs (1)
173req.Host = HostString.FromUriComponent(request.RequestUri);
TestServer.cs (1)
216request.Host = HostString.FromUriComponent(BaseAddress);
WebSocketClient.cs (2)
68? new HostString(HostString.FromUriComponent(uri).Host) 69: HostString.FromUriComponent(uri);