Handle a few other potentially null properties (#10053)
This commit is contained in:
parent
93af64823e
commit
47575a08a5
|
|
@ -81,15 +81,21 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
|
||||||
private void InitializeLocalEndpoint()
|
private void InitializeLocalEndpoint()
|
||||||
{
|
{
|
||||||
var localEndPoint = GetLocalEndPoint();
|
var localEndPoint = GetLocalEndPoint();
|
||||||
LocalIpAddress = localEndPoint.GetIPAddress();
|
if (localEndPoint != null)
|
||||||
LocalPort = localEndPoint.GetPort();
|
{
|
||||||
|
LocalIpAddress = localEndPoint.GetIPAddress();
|
||||||
|
LocalPort = localEndPoint.GetPort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeRemoteEndpoint()
|
private void InitializeRemoteEndpoint()
|
||||||
{
|
{
|
||||||
var remoteEndPoint = GetRemoteEndPoint();
|
var remoteEndPoint = GetRemoteEndPoint();
|
||||||
RemoteIpAddress = remoteEndPoint.GetIPAddress();
|
if (remoteEndPoint != null)
|
||||||
RemotePort = remoteEndPoint.GetPort();
|
{
|
||||||
|
RemoteIpAddress = remoteEndPoint.GetIPAddress();
|
||||||
|
RemotePort = remoteEndPoint.GetPort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeConnectionId()
|
private void InitializeConnectionId()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
@ -14,6 +15,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace TestSite
|
namespace TestSite
|
||||||
|
|
@ -103,6 +105,12 @@ namespace TestSite
|
||||||
public Task CreateFile(HttpContext context)
|
public Task CreateFile(HttpContext context)
|
||||||
{
|
{
|
||||||
var hostingEnv = context.RequestServices.GetService<IWebHostEnvironment>();
|
var hostingEnv = context.RequestServices.GetService<IWebHostEnvironment>();
|
||||||
|
|
||||||
|
if (context.Connection.LocalIpAddress == null || context.Connection.RemoteIpAddress == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to set local and remote ip addresses");
|
||||||
|
}
|
||||||
|
|
||||||
File.WriteAllText(System.IO.Path.Combine(hostingEnv.ContentRootPath, "Started.txt"), "");
|
File.WriteAllText(System.IO.Path.Combine(hostingEnv.ContentRootPath, "Started.txt"), "");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.HttpSys.Internal
|
||||||
_permanentlyPinned = true;
|
_permanentlyPinned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal SafeNativeOverlapped NativeOverlapped => _nativeOverlapped;
|
internal SafeNativeOverlapped NativeOverlapped => _nativeOverlapped;
|
||||||
|
|
||||||
internal HttpApiTypes.HTTP_REQUEST* NativeRequest
|
internal HttpApiTypes.HTTP_REQUEST* NativeRequest
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue