I'm trying to getting server ip addres with
_httpContext.Request.ServerVariables["LOCAL_ADDR"]
It returns null value in scheduled task class.
Is there any other way to get server ip address?
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress address in ipHostInfo.AddressList)
{
if (address.AddressFamily == AddressFamily.InterNetwork)
curServerIP = address.ToString();
}
HttpContext.Current.Request.objects are null in background tasks.
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress address in ipHostInfo.AddressList)
{
if (address.AddressFamily == AddressFamily.InterNetwork)
curServerIP = address.ToString();
}