1 override of Connection
Microsoft.AspNetCore.Http (1)
DefaultHttpContext.cs (1)
148public override ConnectionInfo Connection => _connection ?? (_connection = new DefaultConnectionInfo(Features));
159 references to Connection
AzureAppServicesHostingStartupSample (5)
Startup.cs (5)
29await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + Environment.NewLine); 30await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + Environment.NewLine); 31await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + Environment.NewLine); 32await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + Environment.NewLine); 33await context.Response.WriteAsync("ClientCert: " + context.Connection.ClientCertificate + Environment.NewLine);
AzureAppServicesSample (5)
Startup.cs (5)
40await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + Environment.NewLine); 41await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + Environment.NewLine); 42await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + Environment.NewLine); 43await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + Environment.NewLine); 44await context.Response.WriteAsync("ClientCert: " + context.Connection.ClientCertificate + Environment.NewLine);
Certificate.Optional.Sample (1)
Startup.cs (1)
25new HostString(Program.HostWithCert, context.HttpContext.Connection.LocalPort),
DefaultBuilder.SampleApp (5)
Startup.cs (5)
30await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + "\r\n"); 31await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + "\r\n"); 32await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + "\r\n"); 33await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + "\r\n"); 34await context.Response.WriteAsync("ClientCert: " + context.Connection.ClientCertificate + "\r\n");
Http3SampleApp (1)
Startup.cs (1)
26await context.Response.WriteAsync($"Hello World! {context.Request.Protocol} {context.Connection.ClientCertificate?.Subject}");
HttpOverridesSample (2)
Startup.cs (2)
27await context.Response.WriteAsync($"RemoteIP: {context.Connection.RemoteIpAddress}\r\n"); 28await context.Response.WriteAsync($"RemotePort: {context.Connection.RemotePort}\r\n");
IISSample (5)
Startup.cs (5)
54await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + Environment.NewLine); 55await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + Environment.NewLine); 56await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + Environment.NewLine); 57await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + Environment.NewLine); 58await context.Response.WriteAsync("ClientCert: " + context.Connection.ClientCertificate + Environment.NewLine);
InMemory.FunctionalTests (28)
HttpsConnectionMiddlewareTests.cs (28)
515Assert.NotNull(context.Connection.ClientCertificate); 551Assert.Null(context.Connection.ClientCertificate); 553var clientCert = await context.Connection.GetClientCertificateAsync(); 556Assert.Null(context.Connection.ClientCertificate); 595Assert.Null(context.Connection.ClientCertificate); 597var clientCert = await context.Connection.GetClientCertificateAsync(); 600Assert.NotNull(context.Connection.ClientCertificate); 636Assert.Null(context.Connection.ClientCertificate); 638await Assert.ThrowsAsync<PlatformNotSupportedException>(() => context.Connection.GetClientCertificateAsync()); 679Assert.Null(context.Connection.ClientCertificate); 681var clientCert = await context.Connection.GetClientCertificateAsync(); 684Assert.Null(context.Connection.ClientCertificate); 727Assert.Null(context.Connection.ClientCertificate); 729var clientCert = await context.Connection.GetClientCertificateAsync(); 732Assert.NotNull(context.Connection.ClientCertificate); 769Assert.Null(context.Connection.ClientCertificate); 771var clientCert = await context.Connection.GetClientCertificateAsync(); 774Assert.Null(context.Connection.ClientCertificate); 896Assert.Null(context.Connection.ClientCertificate); 898var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Connection.GetClientCertificateAsync()); 901Assert.Null(context.Connection.ClientCertificate); 1032Assert.Null(context.Connection.ClientCertificate); 1038var clientCert = await context.Connection.GetClientCertificateAsync(); 1041Assert.NotNull(context.Connection.ClientCertificate); 1079Assert.Null(context.Connection.ClientCertificate); 1082var ioe = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Connection.GetClientCertificateAsync()); 1285Assert.NotNull(context.Connection.ClientCertificate); 1286Assert.NotNull(context.Connection.ClientCertificate.PublicKey);
InProcessWebSite (9)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (9)
143var clientCert = context.Connection.ClientCertificate; 182if (context.Connection.LocalIpAddress == null || context.Connection.RemoteIpAddress == null) 366Assert.True(IPAddress.IsLoopback(ctx.Connection.LocalIpAddress)); 367ctx.Connection.LocalIpAddress = IPAddress.IPv6Any; 368Assert.Equal(IPAddress.IPv6Any, ctx.Connection.LocalIpAddress); 370Assert.True(IPAddress.IsLoopback(ctx.Connection.RemoteIpAddress)); 371ctx.Connection.RemoteIpAddress = IPAddress.IPv6Any; 372Assert.Equal(IPAddress.IPv6Any, ctx.Connection.RemoteIpAddress);
Interop.FunctionalTests (14)
Http3\Http3RequestTests.cs (6)
1410connectionId = context.Connection.Id; 1946connectionId = context.Connection.Id; 1947remoteAddress = context.Connection.RemoteIpAddress; 1948remotePort = context.Connection.RemotePort; 1949localAddress = context.Connection.LocalIpAddress; 1950localPort = context.Connection.LocalPort;
Http3\Http3TlsTests.cs (4)
82var hasCert = context.Connection.ClientCertificate != null; 124var hasCert = context.Connection.ClientCertificate != null; 169var hasCert = context.Connection.ClientCertificate != null; 223var hasCert = context.Connection.ClientCertificate != null;
HttpClientHttp2InteropTests.cs (4)
1620Assert.NotNull(context.Connection.ClientCertificate); 1621Assert.NotNull(await context.Connection.GetClientCertificateAsync()); 1665Assert.Null(context.Connection.ClientCertificate); 1666Assert.Null(await context.Connection.GetClientCertificateAsync());
Kestrel.SampleApp (2)
Startup.cs (2)
51var cert = await context.Connection.GetClientCertificateAsync(); 53var connectionFeature = context.Connection;
Microsoft.AspNetCore.Authentication.Certificate (1)
CertificateAuthenticationHandler.cs (1)
59var clientCertificate = await Context.Connection.GetClientCertificateAsync();
Microsoft.AspNetCore.Authentication.Test (1)
CertificateTests.cs (1)
806context.Connection.ClientCertificate = clientCertificate;
Microsoft.AspNetCore.Diagnostics.HealthChecks (1)
Builder\HealthCheckApplicationBuilderExtensions.cs (1)
215(port == null || c.Connection.LocalPort == port) &&
Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests (5)
HealthCheckMiddlewareTests.cs (5)
713context.Connection.LocalPort = context.Request.Host.Port.Value; 751context.Connection.LocalPort = context.Request.Host.Port.Value; 789context.Connection.LocalPort = context.Request.Host.Port.Value; 825context.Connection.LocalPort = context.Request.Host.Port.Value; 869context.Connection.LocalPort = context.Request.Host.Port.Value;
Microsoft.AspNetCore.Grpc.JsonTranscoding (2)
Internal\JsonTranscodingServerCallContext.cs (2)
82var connection = HttpContext.Connection; 188var clientCertificate = HttpContext.Connection.ClientCertificate;
Microsoft.AspNetCore.Http.Connections.Tests (5)
HttpConnectionDispatcherTests.cs (5)
825Assert.Equal("connectionid", connectionHttpContext.Connection.Id); 826Assert.Equal(IPAddress.Loopback, connectionHttpContext.Connection.LocalIpAddress); 827Assert.Equal(4563, connectionHttpContext.Connection.LocalPort); 828Assert.Equal(IPAddress.IPv6Any, connectionHttpContext.Connection.RemoteIpAddress); 829Assert.Equal(43456, connectionHttpContext.Connection.RemotePort);
Microsoft.AspNetCore.Http.Tests (2)
DefaultHttpContextTests.cs (2)
329TestCachedFeaturesAreNull(context.Connection, features); 357TestCachedFeaturesAreSet(context.Connection, features);
Microsoft.AspNetCore.HttpLogging (1)
W3CLoggingMiddleware.cs (1)
100var connectionInfo = context.Connection;
Microsoft.AspNetCore.HttpOverrides (1)
ForwardedHeadersMiddleware.cs (1)
209var connection = context.Connection;
Microsoft.AspNetCore.HttpOverrides.Tests (37)
CertificateForwardingTest.cs (11)
53Assert.Null(context.Connection.ClientCertificate); 59Assert.Equal(context.Connection.ClientCertificate, Certificates.SelfSignedValidWithNoEku); 91Assert.Null(context.Connection.ClientCertificate); 92context.Connection.ClientCertificate = Certificates.SelfSignedNotYetValid; 98Assert.Equal(context.Connection.ClientCertificate, Certificates.SelfSignedValidWithNoEku); 130Assert.Null(context.Connection.ClientCertificate); 136Assert.Equal(context.Connection.ClientCertificate, Certificates.SelfSignedValidWithNoEku); 168Assert.Null(context.Connection.ClientCertificate); 174Assert.Null(context.Connection.ClientCertificate); 206Assert.Null(context.Connection.ClientCertificate); 212Assert.Null(context.Connection.ClientCertificate);
ForwardedHeadersMiddlewareTest.cs (26)
43Assert.Equal("11.111.111.11", context.Connection.RemoteIpAddress.ToString()); 44Assert.Equal(9090, context.Connection.RemotePort); 77c.Connection.RemoteIpAddress = IPAddress.Parse("10.0.0.1"); 78c.Connection.RemotePort = 99; 81Assert.Equal(expectedIp, context.Connection.RemoteIpAddress.ToString()); 82Assert.Equal(expectedPort, context.Connection.RemotePort); 135c.Connection.RemoteIpAddress = IPAddress.Parse("10.0.0.1"); 136c.Connection.RemotePort = 99; 139Assert.Equal(expectedIp, context.Connection.RemoteIpAddress.ToString()); 140Assert.Equal(expectedPort, context.Connection.RemotePort); 173c.Connection.RemoteIpAddress = IPAddress.Parse(originalIp); 174c.Connection.RemotePort = 99; 179Assert.Equal("10.0.0.1", context.Connection.RemoteIpAddress.ToString()); 180Assert.Equal(1234, context.Connection.RemotePort); 187Assert.Equal(originalIp, context.Connection.RemoteIpAddress.ToString()); 188Assert.Equal(99, context.Connection.RemotePort); 246c.Connection.RemoteIpAddress = IPAddress.Parse("10.0.0.1"); 247c.Connection.RemotePort = 99; 250Assert.Equal(expectedIp, context.Connection.RemoteIpAddress.ToString()); 251Assert.Equal(expectedPort, context.Connection.RemotePort); 280Assert.Null(context.Connection.RemoteIpAddress); 879c.Connection.RemoteIpAddress = IPAddress.Parse(remoteIp); 924Assert.Equal("11.111.111.11", context.Connection.RemoteIpAddress.ToString()); 959Assert.Null(context.Connection.RemoteIpAddress); 992Assert.Equal("11.111.111.11", context.Connection.RemoteIpAddress.ToString()); 1045Assert.Equal(expectedRemoteIp, context.Connection.RemoteIpAddress.ToString());
Microsoft.AspNetCore.Rewrite (6)
PatternSegments\IsIPV6Segment.cs (2)
12if (context.HttpContext.Connection.RemoteIpAddress == null) 16return context.HttpContext.Connection.RemoteIpAddress.AddressFamily == AddressFamily.InterNetworkV6 ? "on" : "off";
PatternSegments\LocalAddressSegment.cs (1)
10return context.HttpContext.Connection.LocalIpAddress?.ToString();
PatternSegments\LocalPortSegment.cs (1)
12return context.HttpContext.Connection.LocalPort.ToString(CultureInfo.InvariantCulture);
PatternSegments\RemoteAddressSegment.cs (1)
10return context.HttpContext.Connection.RemoteIpAddress?.ToString();
PatternSegments\RemotePortSegment.cs (1)
12return context.HttpContext.Connection.RemotePort.ToString(CultureInfo.InvariantCulture);
Microsoft.AspNetCore.Rewrite.Tests (9)
PatternSegments\IsIPV6SegmentTests.cs (3)
18context.HttpContext.Connection.RemoteIpAddress = null; 33context.HttpContext.Connection.RemoteIpAddress = IPAddress.Parse("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); 48context.HttpContext.Connection.RemoteIpAddress = IPAddress.Parse("20.30.40.50");
PatternSegments\LocalAddressSegmentTests.cs (2)
18context.HttpContext.Connection.LocalIpAddress = IPAddress.Parse("20.30.40.50"); 31context.HttpContext.Connection.LocalIpAddress = null;
PatternSegments\LocalPortSegmentTests.cs (1)
17context.HttpContext.Connection.LocalPort = 800;
PatternSegments\RemoteAddressSegmentTests.cs (2)
18context.HttpContext.Connection.RemoteIpAddress = IPAddress.Parse("20.30.40.50"); 31context.HttpContext.Connection.RemoteIpAddress = null;
PatternSegments\RemotePortSegmentTests.cs (1)
17context.HttpContext.Connection.RemotePort = 800;
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (1)
Http2Tests.cs (1)
407httpContext.Connection.RequestClose();
Microsoft.AspNetCore.TestHost.Tests (1)
ClientHandlerTests.cs (1)
270context.Connection.RemoteIpAddress = IPAddress.Parse("1.1.1.1");
NativeIISSample (5)
Startup.cs (5)
48await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + Environment.NewLine); 49await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + Environment.NewLine); 50await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + Environment.NewLine); 51await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + Environment.NewLine); 52await context.Response.WriteAsync("ClientCert: " + context.Connection.ClientCertificate + Environment.NewLine);
Sockets.FunctionalTests (3)
SocketTransportTests.cs (2)
41Assert.Equal(ip.Address, context.Connection.RemoteIpAddress); 42Assert.Equal(ip.Port, context.Connection.RemotePort);
src\Servers\Kestrel\test\FunctionalTests\RequestTests.cs (1)
1105var connection = context.Connection;
SystemdTestApp (1)
Startup.cs (1)
27var connectionFeature = context.Connection;