Skip to content

Commit

Permalink
Merge pull request #6469 from Urtgard/dev
Browse files Browse the repository at this point in the history
Added null check for remoteIpAdress in HttpContextClientInfoProvider.GetComputerName
  • Loading branch information
ismcagdas committed Jun 10, 2022
2 parents 55e85ea + 4adcbee commit 098e71c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using Abp.Auditing;
using Abp.Auditing;
using Castle.Core.Logging;
using Microsoft.AspNetCore.Http;
using Abp.Extensions;
using System;
using System.Net;

namespace Abp.AspNetCore.Mvc.Auditing
Expand Down Expand Up @@ -56,8 +55,11 @@ protected virtual string GetComputerName()
try
{
var httpContext = _httpContextAccessor.HttpContext;
return Dns.GetHostEntry(httpContext?.Connection?.RemoteIpAddress).HostName;
var remoteIpAddress = httpContext?.Connection?.RemoteIpAddress;

if (remoteIpAddress is null) return null;

return Dns.GetHostEntry(remoteIpAddress).HostName;
}
catch (Exception ex)
{
Expand Down

0 comments on commit 098e71c

Please sign in to comment.