How to get User’s location - City State

Asked

Viewed 477 times

0

I wonder how do I get user location so that I can make my systems automatically select the city of Dropdownlist City.

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

Line I’m having trouble

LookupService servico = new LookupService(database);

Below I describe the procedures described by the author

First we should download a file containing database of already registered locations File with database

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);
            }
  • You’re pretty sure this is ASP.NET MVC, if it is, it’s very wrong. This looks like ASP. in C#.

  • @Maniero as I said I took this information and I’m trying to adapt it in my project the link access to the tutorial is this. http://thiagomarcal.blogspot.com.br/2010/08/localizacao-de-usuario-obter-cidade-e.html

  • @Maniero if you have a succinct solution regarding my doubt can pass.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.