¿Cómo llamo a un método estático? Quiero llamar a esto desde una clase que he creado, quiero obtener la ubicación de IP. He declarado, pero lo que hay que hacer es llamar al método ... ... como static
Llamar a un método estático en C#
para ser honesto con ustedes, estoy bastante confundido aquí, ¿necesito para crear una instancia address
, city
, etc. .?
He hecho esto hasta el momento;
LocationTools.cs
public static class LocationTools
{
public static void GetLocationFromIP(string address, out string city, out string region, out string country, out double? latitude, out double? longitude)
{
Home.cs
public string IPAPIKey
{
get
{
return WebConfigurationManager.AppSettings["IPAPIKey"];
}
}
////To get the ip address of the machine and not the proxy use the following code
static void GetLocationFromIP()
{
string strIPAddress = Request.UserHostAddress.ToString();
strIPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIPAddress == null || strIPAddress == "")
{
strIPAddress = Request.ServerVariables["REMOTE_ADDR"].ToString();
}
}
}
}
¿qué has probado? solo use LocationTools.GetLocationFromIP (...); –