Jak wywołać metodę statyczną? Chcę to nazwać z klasy, którą stworzyłem, chcę uzyskać lokalizację z IP. Mam ogłosił go jednak to, co trzeba zrobić, to wywołać metodę ... jak static
...Wywołanie metody statycznej w języku C#
Aby być z tobą szczery, jestem bardzo mylić tutaj, muszę instancję address
, city
, etc .?
Zrobiłem to do tej pory;
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();
}
}
}
}
co spróbowałeś? po prostu użyj LocationTools.GetLocationFromIP (...); –