In Asp.Net Core core how to I get the web site's IP address?

You can use HttpContext.Features.Get<IHttpConnectionFeature>() - docs:

var httpConnectionFeature = httpContext.Features.Get<IHttpConnectionFeature>();
var localIpAddress = httpConnectionFeature?.LocalIpAddress;

This is what worked for me using .net core 2.1

Adjust the regex to your needs. My prod web servers are in the 10.168.x.x range. my dev machine is in the 10.60.x.x range.

if(String.IsNullOrEmpty(localIpAddress))
{
    var ips = await System.Net.Dns.GetHostAddressesAsync(System.Net.Dns.GetHostName());

    string rgx = (env.IsDevelopment()) ? @"10{1}\.60{1}\..*" : @"10{1}\.168{1}\..*";
    var result = ips.FirstOrDefault(x => {
        Match m2 = Regex.Match(x.ToString(), rgx);
        return m2.Captures.Count >= 1;
    });
    localIpAddress = result.ToString();
}

Although in the end I ended up just using System.Net.Dns.GetHostName() because I didn't really need the IP address.