How to get User's location - City State

0

I would like to know how do I get the user's location so I can make my systems automatically select the city from the DropDownList City.

Through a blog the author teaches how to do this development that I even tried to accomplish it, but I'm having problems with the LookupService library that I did not find in the Visual Studio Nuget and thus I can not use the using of this library. >

Line I'm having a problem

LookupService servico = new LookupService(database);

Below I describe the procedures described by the author

First we must download a database file from already registered locations Database file

After this we use this code below, which I could not use it for reasons described above.

string database = Server.MapPath("~/Content/LocalizaUsuario/GeoLiteCity.dat");
            LookupService servico = new LookupService(database);
            Location localizacao = servico.getLocation(Request.ServerVariables["REMOTE_ADDR"]);
            if (localizacao != null)
            {
                Response.Write("Cidade: " + localizacao.city + "<br />");
                Response.Write("País: " + localizacao.countryName + "<br />");
                Response.Write("Código do País: " + localizacao.countryCode + "<br />");
                Response.Write("Região: " + localizacao.region + "<br />");
                Response.Write("Código da Área: " + localizacao.area_code + "<br />");
                Response.Write("Latitude: " + localizacao.latitude + "<br />");
                Response.Write("Longitudade: " + localizacao.longitude);
            }
    
asked by anonymous 09.11.2017 / 04:30

0 answers