I need to get the client's IP address in .net standard 2.1 class library application.
I am using the code below, It works as expected in the .net framework, but its giving compilation error in .net standard.
private string IPAddress { get { return HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } }
Error CS1061 'HttpRequest' does not contain a definition for 'ServerVariables' and no accessible extension method 'ServerVariables' accepting a first argument of type 'HttpRequest' could be found (are you missing a using directive or an assembly reference?)