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()
|
||||
{
|
||||
var localEndPoint = GetLocalEndPoint();
|
||||
LocalIpAddress = localEndPoint.GetIPAddress();
|
||||
LocalPort = localEndPoint.GetPort();
|
||||
if (localEndPoint != null)
|
||||
{
|
||||
LocalIpAddress = localEndPoint.GetIPAddress();
|
||||
LocalPort = localEndPoint.GetPort();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeRemoteEndpoint()
|
||||
{
|
||||
var remoteEndPoint = GetRemoteEndPoint();
|
||||
RemoteIpAddress = remoteEndPoint.GetIPAddress();
|
||||
RemotePort = remoteEndPoint.GetPort();
|
||||
if (remoteEndPoint != null)
|
||||
{
|
||||
RemoteIpAddress = remoteEndPoint.GetIPAddress();
|
||||
RemotePort = remoteEndPoint.GetPort();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
|
@ -14,6 +15,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace TestSite
|
||||
|
|
@ -103,6 +105,12 @@ namespace TestSite
|
|||
public Task CreateFile(HttpContext context)
|
||||
{
|
||||
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"), "");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.HttpSys.Internal
|
|||
_permanentlyPinned = true;
|
||||
}
|
||||
|
||||
|
||||
internal SafeNativeOverlapped NativeOverlapped => _nativeOverlapped;
|
||||
|
||||
internal HttpApiTypes.HTTP_REQUEST* NativeRequest
|
||||
|
|
|
|||
Loading…
Reference in New Issue